matlab绘图坐标轴字体_MATLAB绘图(轴文本粗体,曲线粗体),Matlab,坐标轴,文字,加粗...

本文介绍了如何使用MATLAB绘制折线图,并着重讲解如何设置坐标轴字体加粗,包括_xlabel_和_ylabel_的文字加粗,以及图例和坐标轴刻度的调整,提供了一段完整的代码示例。

最近用matlab绘制折线图,有一些常用的指令记录下来。

首先是加速比的程序代码,具体功能记录在注释里面。

x1 = [8 16 32 64 128 256];

x2 = [32 64 128 256];

y = [1 2 4 8 16 32];

y04 = [1 1.7872 3.3846 6.6000 11.8800 15.0666];

y02 = [1.0000 1.7770 3.44216.5401 12.5571 24.7838];

y01 = [1 1.92453.4636 5.3699];

y005 = [1 1.9240 3.51246.8844]; % 定义的数组

set(gcf,'color','white'); % 设置背景是白色的 原先是灰色的 论文里面不好看

plot(x1,y,'b-','LineWidth',2) % 绘制曲线 设置线宽是2

hold on

plot(x1,y04,'rs-','LineWidth',2)

hold on

plot(x1,y02,'md-','LineWidth',2)

hold on

plot(x2,y01,'rd--','LineWidth',2)

hold on

plot(x2,y005,'bs--','LineWidth',2)

xlabel('节点数','FontWeight','bold') % 横坐标的文字是 加粗的

ylabel({'加','速','比'},'Rotation',0,'FontWeight','bold') % 对于多个文字组成的一定要加大括号 这个语句实现了文字的翻转 使得文字朝向变成了正的

%title('程序加速比') % 标题

legend({'理想','0.04','0.02','0.01','0.005'},'FontSize',8,'FontWeight','bold')

% 图例 多个文字组成的 一定要加大括号 才能使得后面设置的 文字大小 文字加粗效果实现

axis([0 272 0 32]) % 设置坐标轴的范围

set(gca, 'XTick',(0:16:280)) % 设置x坐标轴的刻度

set(gca, 'YTick',(0:2:32)) % 设置y坐标轴的刻度

set(gca, 'FontSize',8) % 设置坐标轴字体是 8

grid on % 显示网格

具体效果如下:

并行效率的代码也是类似的:

x1 = [8 16 32 64 128 256];

x2 = [32 64 128 256];

y = [1 2 4 8 16 32];

y04 = [1.0000.89360.84620.82500.74250.4708];

y02 = [1.0000.88850.86050.81750.78480.7744];

y01 = [10.96220.86590.8213];

y005 = [10.9620.87810.8605];

set(gcf,'color','white');

%plot(x1,y,'b-','LineWidth',2)

%hold on

plot(x1,y04,'rs-','LineWidth',2)

%legend('x','y')

hold on

plot(x1,y02,'md-','LineWidth',2)

hold on

plot(x2,y01,'rd--','LineWidth',2)

hold on

plot(x2,y005,'bs--','LineWidth',2)

xlabel('进程数(节点数)','FontWeight','bold')

ylabel({'并','行','效','率'},'Rotation',0,'FontWeight','bold')

%title('程序加速比')

legend({'0.04','0.02','0.01','0.005'},'FontSize',8,'FontWeight','bold')

set(gca, 'FontSize',8)

axis([0 272 0.4 1])

set(gca, 'XTick',(0:16:280))

set(gca, 'YTick',(0.4:0.05:1))

grid on

结果如下图所示:

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值