MATLAB Answers

2

RGB values for 2014b default colors

Asked by Alexandre Laurin on 27 Oct 2014
Latest activity Answered by EvilDrW
on 24 Oct 2017
Hi guys, I love the new default colors in 2014b. I would, however, be able to use then to color lines out of order sometimes. Any idea what their RGB values are?
thanks -Alex

5 Answers

Answer by Mike Garrity
on 28 Oct 2014
 Accepted Answer

The simplest way is the ColorOrder property on the axes.
get(gca,'ColorOrder')
To get the values without an axes, you can do this:
get(groot,'DefaultAxesColorOrder')

  2 Comments

Hi Alex very nice question, it was very useful for me.

Sign in to comment.


Answer by Star Strider
on 28 Oct 2014

The new default colormap is called ‘parula’. To get 8 RGB values of it, use the colormap function:
cmp = colormap(parula(8));
to return them in the ‘cmp’ variable. To get more values, change the ‘8’ to the number you want.

  1 Comment

Thanks for the answer, Star Strider. I should have been clearer. I was looking for the RGB of the default colors when plotting lines or 2-D graphs.

Sign in to comment.


Answer by Image Analyst
on 28 Oct 2014

See my attached demo, below the image.
You can select several standard demo images and several standard colormaps. The images are displayed with the colormap and the RGB curves for the color map are plotted.

  11 Comments

Tuned the above to get what I was looking for. Thank you again! :)
t = linspace(0,1,lineCount)';
s = 1/2 + zeros(lineCount,1);
v = 0.8*ones(lineCount,1);
lineColors = colormap(squeeze(hsv2rgb(t,s,v)))
ax=gca
ax.ColorOrder = lineColors;
> Oh dear. You've just created a monster! ;)
Creating graphics monsters is the best part of my job!
...if only you could help me tame the oversized space-hogging legend box in a simple way, and I'd be set until the next update of Matlab... :) :) (See this question .)

Sign in to comment.


Answer by Image Analyst
on 28 Oct 2014

To change the default color order, see my demo, attached below the image.
A variety of color orders are presented for you to pick from or you can adapt it to customize it completely to the exact colors you want.

  0 Comments

Sign in to comment.


Answer by EvilDrW
on 24 Oct 2017

you want the command "lines"...
lineColors = lines(8)
the methods above that use
get(gca, 'ColorOrder')
seem to only give you the first 7 line colors, where the lines command allows you to specify the number of colors you want and also doesn't rely on having an active axis to get your rgb color values.

  0 Comments

Sign in to comment.