Matlab绘图(坐标轴文字加粗,曲线加粗)

最近用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.4421	6.5401 12.5571 24.7838];
y01 = [1 1.9245	3.4636 5.3699];
y005 = [1 1.9240 3.5124	6.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.000	0.8936	0.8462	0.8250	0.7425	0.4708];
y02 = [1.000	0.8885	0.8605	0.8175	0.7848	0.7744];
y01 = [1	0.9622	0.8659	0.8213];
y005 = [1	0.962	0.8781	0.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

结果如下图所示:

  • 27
    点赞
  • 181
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值