Line Styles Used for Plotting — LineStyleOrder

The axes LineStyleOrder property is analogous to the ColorOrder property. It specifies the line styles to use for multiline plots created with the line-plotting functions.

Axes increments the line style only after using all of the colors in the ColorOrder property. It then uses all the colors again with the second line style, and so on.

For example, define a default ColorOrder of red, green, and blue and a default LineStyleOrder of solid, dashed, and dotted lines.

set(groot,'defaultAxesColorOrder',[1 0 0;0 1 0;0 0 1],...
      'defaultAxesLineStyleOrder','-|--|:')

Then plot some multiline data.

t = 0:pi/20:2*pi;
a = ones(length(t),9);
for i = 1:9
    a(:,i) = sin(t-i/5)';
end
plot(t,a)

Plotting functions cycle through all colors for each line style.

The default values persist until you quit MATLAB®. To remove default values during your MATLAB session, use the reserved word remove.

set(groot,'defaultAxesLineStyleOrder','remove')
set(groot,'defaultAxesColorOrder','remove')

See Default Property Values for more information.

Was this topic helpful?