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

标签:
转载 |
分类: Matlab |
原文地址:Matlab plot多条曲线,自动使用不同线型 作者:ronei
先定义几个变量:
x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = sin(x-pi/2);
y3 = sin(x-pi);
那么matlab将自动使用不同的颜色来区别这三条曲线。
效果如下:
http://s3/middle/618af195g970d9a806ba2&690plot多条曲线,自动使用不同线型" TITLE="[转载]Matlab plot多条曲线,自动使用不同线型" />
但是有的时候,为了保证黑白打印的时候也能区分不同曲线,就要用不同线型来区分。怎么样让matlab自动做这件事呢。
但是有的时候,为了保证黑白打印的时候也能区分不同曲线,就要用不同线型来区分。怎么样让matlab自动做这件事呢。
mathworks上是这么说的
You can configure MATLAB defaults to use line styles instead of
colors for multiline plots by setting a value for the
axes
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')