EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 uperrua 于 2020-8-5 13:21 编辑 , f3 o9 n/ z+ b( @; `' m1 r
* o- U, P3 u+ t先定义几个变量:& \" {4 w; r' Q0 o9 U) ?( m* [9 N: q" Y) e
x = 0:pi/10:2*pi;5 L, J3 N7 z x1 @9 Z- [7 N6 A
y1 = sin(x);
" q G1 n0 j" a0 ^8 ?. hy2 = sin(x-pi/2);5 f! ^; @: J& V
y3 = sin(x-pi);! ], K& P8 [7 f
5 ^, C5 p f) Z
" U N* `9 O, @5 D& M2 u+ c% g3 Wmatlab作图的时候,如果直接使用plot(x,y1,x,y2,x,y3);那么matlab将自动使用不同的颜色来区别这三条曲线。
1 ^4 k7 b7 R E效果如下:6 e; [" r( Y, B
0 x: \( `8 [" Z' M2 D
7 y" x: @. I( [8 w但是有的时候,为了保证黑白打印的时候也能区分不同曲线,就要用不同线型来区分。怎么样让matlab自动做这件事呢。
2 x3 G) e+ O s3 T; A5 y g1 ~1 B6 d& c/ X, E5 d# Z
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]);
0 |& R% t+ W( p0 _1 [6 s也就是说在plot(x,y1,x,y2,x,y3);的前面加上这两句话,set(0,'DefaultAxesLineStyleOrder',{'-o',':s','--+'})set(0,'DefaultAxesColorOrder',[0.4,0.4,0.4]);这回效果如下:
% G6 L; P# _( ^6 K
+ {8 r; b0 Q8 l# y9 f
The default values persist until you quit MATLAB. To remove default values during your MATLAB session, use the reserved word remove.
7 s8 x4 B0 ]$ ] X9 a f9 }
0 S% I1 k8 w1 C$ \$ ^' j1 A- H3 J+ F. U: ]3 D. o
set(0,'DefaultAxesLineStyleOrder','remove') set(0,'DefaultAxesColorOrder','remove')5 c# A( G. d! Z( D6 v# S
9 R" M4 t. d% m' a
|