加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

[转载]Matlab plot多条曲线,自动使用不同线型

(2015-11-26 19:14:32)
标签:

转载

分类: Matlab
先定义几个变量:
x  = 0:pi/10:2*pi;
y1 = sin(x);
y2 = sin(x-pi/2);
y3 = sin(x-pi);

matlab作图的时候,如果直接使用plot(x,y1,x,y2,x,y3);
那么matlab将自动使用不同的颜色来区别这三条曲线。
效果如下:

http://s3/middle/618af195g970d9a806ba2&690plot多条曲线,自动使用不同线型" TITLE="[转载]Matlab plot多条曲线,自动使用不同线型" />
但是有的时候,为了保证黑白打印的时候也能区分不同曲线,就要用不同线型来区分。怎么样让matlab自动做这件事呢。
mathworks上是这么说的

You can configure MATLAB defaults to use line styles instead of colors for multiline plots by setting a value for the axes LineStyleOrder property using a cell array of linespecs. For example, the command


set(0,'DefaultAxesLineStyleOrder',{'-o',':s','--+'})

defines three line styles and makes them the default for all plots.

To set the default line color to dark gray, use the statement


set(0,'DefaultAxesColorOrder',[0.4,0.4,0.4]);



也就是说在plot(x,y1,x,y2,x,y3);的前面加上这两句话,


set(0,'DefaultAxesLineStyleOrder',{'-o',':s','--+'})

set(0,'DefaultAxesColorOrder',[0.4,0.4,0.4]);

这回效果如下:

http://s3/middle/618af195g970da7486d12&690plot多条曲线,自动使用不同线型"  TITLE="[转载]Matlab plot多条曲线,自动使用不同线型" />

The default values persist until you quit MATLAB. To remove default values during your MATLAB session, use the reserved word remove.





set(0,'DefaultAxesLineStyleOrder','remove')
set(0,'DefaultAxesColorOrder','remove')


0

  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有