Documentation Center

  • Trial Software
  • Product Updates

Change Default Line Style and Color Orders

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])

See ColorSpec for information on how to specify color as a three-element vector of RGB values.

Now the plot function 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 for more information.

Was this topic helpful?