EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
本帖最后由 uperrua 于 2020-8-5 13:21 编辑 ! |0 G# l, U8 Q' d
* M7 e. \5 g8 c" f" E. \先定义几个变量:
% T. G1 E' O! w4 [- @x = 0:pi/10:2*pi;
- D9 q# ?9 W; ?! By1 = sin(x);0 r4 a! n$ O7 H2 {
y2 = sin(x-pi/2);5 X& }% c, {* T0 S
y3 = sin(x-pi);) ?2 C4 z$ S2 i
6 l2 ?: j! b( ~* _ G [. d
4 t9 |0 ?& x" u/ R7 M. d# smatlab作图的时候,如果直接使用plot(x,y1,x,y2,x,y3);那么matlab将自动使用不同的颜色来区别这三条曲线。
& P$ U2 d9 ^3 T; f9 x0 F% C. ?效果如下:! H$ H/ D* [2 H% A- i0 i
- S9 k" u+ J1 `( F3 d" Q
4 x" y+ ]' D) U6 `4 d8 |( y' \. }
但是有的时候,为了保证黑白打印的时候也能区分不同曲线,就要用不同线型来区分。怎么样让matlab自动做这件事呢。7 V% \; ?7 H, w/ N( n
/ ~% h2 `& |3 S- L* O0 |* D! @ [
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]);; B% `* @1 Y% q/ j% O
也就是说在plot(x,y1,x,y2,x,y3);的前面加上这两句话,set(0,'DefaultAxesLineStyleOrder',{'-o',':s','--+'})set(0,'DefaultAxesColorOrder',[0.4,0.4,0.4]);这回效果如下:
; [$ Q* t8 h" E
: O j* C1 O3 ` j7 {
The default values persist until you quit MATLAB. To remove default values during your MATLAB session, use the reserved word remove.
2 W9 s+ A5 }5 K8 N* s3 n b1 @! U: p m" g
- n6 }; _( I" i) O" b
set(0,'DefaultAxesLineStyleOrder','remove') set(0,'DefaultAxesColorOrder','remove')7 C9 K3 y% J/ f5 s- ~
7 r1 c# E' E t% {6 W |