Graphics | ![]() ![]() |
Setting Default Line Styles
You can configure MATLAB to use line styles instead of colors for multi-line plots by setting a default value for the axes LineStyle
property. 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])
See ColorSpec
for information on how to specify color as a three-element vector of RGB values.
Now the plot command uses the line styles and colors you have defined as defaults. For example, these statements create a multiline plot.
x = 0:pi/10:2*pi; y1 = sin(x); y2 = sin(x-pi/2); y3 = sin(x-pi); plot(x,y1,x,y2,x,y3)
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')
See "Setting Default Property Values" in the "Handle Graphics Objects" chapter for more information.
![]() | Line Styles for Black and White Output | Line Plots of Matrix Data | ![]() |