MATLAB Answers


Why are plot lines colored differently in MATLAB R2014b compared to previous releases of MATLAB?

I am trying to plot multiple lines using a single plot command. For example, the command that I use is :
The line colors that I see in MATLAB R2014b are different from MATLAB R2014a. Why is that so?




1 Answer

Answer by MathWorks Support Team on 10 Apr 2015
 Accepted Answer

The behavior seen in MATLAB R2014b is due to a new color order. The details are explained below:
Starting in R2014b, MATLAB® graphics has a new color order that determines the colors used in plots. This is the color order introduced in R2014b and the RGB triplet values that define the colors:
         0    0.4470    0.7410
    0.8500    0.3250    0.0980
    0.9290    0.6940    0.1250
    0.4940    0.1840    0.5560
    0.4660    0.6740    0.1880
    0.3010    0.7450    0.9330
    0.6350    0.0780    0.1840
This is the color order in R2014a and earlier.
         0         0    1.0000
         0    0.5000         0
    1.0000         0         0
         0    0.7500    0.7500
    0.7500         0    0.7500
    0.7500    0.7500         0
    0.2500    0.2500    0.2500
The 'ColorOrder' property of the axes contains the color order. To change the color order, set a different default value for the 'ColorOrder' property. For example, this code sets the default color order to the colors used in previous releases.  An enhancement request has been submitted to make it easier to go back to the previous release color order.
co = [0,0,1;
The hold Command Cycles Through Colors
In previous releases, the 'hold on' command does not retain the current color so new plots added to the axes start from the beginning of the color order. Visually, this means that new plots use the same initial color. Starting in R2014b, the 'hold on' command retains the current color so that new plots added to the axes use the next colors in the color order.
For example, this code displays three lines using the 'hold on' command.
hold on
hold off
In R2014a and earlier, the lines use the first color from the color order.
Starting in R2014b, the lines cycle through the color order.
If you want to plot multiple lines using the same color in R2014b, then set the Color property for each line to the same value. For example, plot the three lines using the same RGB triplet color value.
rgbcolor = [0 0.447 0.741];
hold on
hold off


Sign in to comment.