RGB values for 2014b default colors

56 ビュー (過去 30 日間)
Alexandre Laurin
Alexandre Laurin 2014 年 10 月 27 日
コメント済み: Michael Sonnenberg 2020 年 4 月 24 日
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

採用された回答

Mike Garrity
Mike Garrity 2014 年 10 月 28 日
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')
  3 件のコメント
arthur Le Gall
arthur Le Gall 2017 年 8 月 23 日
Hi Alex very nice question, it was very useful for me.
Michael Sonnenberg
Michael Sonnenberg 2020 年 4 月 24 日
Agreed, thanks for the question and answer.

サインインしてコメントする。

その他の回答 (4 件)

Star Strider
Star Strider 2014 年 10 月 28 日
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 件のコメント
Alexandre Laurin
Alexandre Laurin 2014 年 10 月 28 日
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.

サインインしてコメントする。


Image Analyst
Image Analyst 2014 年 10 月 28 日
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.
  3 件のコメント
Ageb Kara
Ageb Kara 2020 年 1 月 22 日
Dear,
I am trying to find the best way to plot the spectrum (x,y), where x-wavenegths, y=intesity, in a way to fill 2D graph with the corresponding color of the wavelength?
How would you suggest to do this?
Kindlydf.png
Image Analyst
Image Analyst 2020 年 1 月 23 日
Ageb, I'd probably create an image and use image() or imshow() to display it. I'd make each column from the bottom of the image up to the black curve be a color map value. Use jet() or hsv() to create the colormap. Start a new thread if you still need help. And say how many columns you'd like the image to have (can be as many as how many columns your screen has).

サインインしてコメントする。


Image Analyst
Image Analyst 2014 年 10 月 28 日
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 件のコメント
Mike Garrity
Mike Garrity 2014 年 11 月 11 日
> Oh dear. You've just created a monster! ;)
Creating graphics monsters is the best part of my job!
Hrefna
Hrefna 2014 年 11 月 12 日
...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 .)

サインインしてコメントする。


EvilDrW
EvilDrW 2017 年 10 月 24 日
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.
  1 件のコメント
Stephen23
Stephen23 2019 年 6 月 21 日
編集済み: Stephen23 2019 年 6 月 21 日
"to only give you the first 7 line colors"
There are only seven colors in the default line ColorOrder, so you can't get more.
"...where the lines command allows you to specify the number of colors you want"
Not really. You can certainly return a colormap of the size that you request, but the colors will repeat if you request more colors than the line ColorOrder has, so you will not get more than seven unique colors (assuming the default line ColorOrder of seven colors).
You can check this quite easily by looking at the lines code, or with a simple example:
>> lines(8) % only 7 colors in the ColorOrder
ans =
0 0.447 0.741 % duplicate!
0.85 0.325 0.098
0.929 0.694 0.125
0.494 0.184 0.556
0.466 0.674 0.188
0.301 0.745 0.933
0.635 0.078 0.184
0 0.447 0.741 % duplicate!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by