default figure color order

51 ビュー (過去 30 日間)
Corey Fugate
Corey Fugate 2012 年 1 月 16 日
回答済み: Steven 2014 年 9 月 19 日
I have a figure with two data sets, one is blue and the other is dark green. I didn't specify the colors. I need to find out what the colors are so that when I make other figures and can keep the color constant, data set one = blue, data set two = dark green.
Everything I read online about color is for making color gradients, I just need to figure out what the default color values are. Thanks!

採用された回答

the cyclist
the cyclist 2012 年 1 月 16 日
Here is some info to supplement what Image Analyst quoted from the help file:
h = plot(1:10,1:10,1:10,2:11);
c = get(h,'Color')
c{1}
c{2}
Here, I've used the plot command with an output, which is the "handle" to the plotted lines. Then I "get" the colors of those lines. "c" is a cell array with one element per line. Each element of c is an RGB vector (1x3) specifying the value of the color.
  1 件のコメント
Corey Fugate
Corey Fugate 2012 年 1 月 17 日
Wow, that was really helpful. Thanks!

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

その他の回答 (2 件)

Steven
Steven 2014 年 9 月 19 日
If you just want to know the default color before plotting, you can try
get(gca,'colororder')

Image Analyst
Image Analyst 2012 年 1 月 16 日
From the help:
plot automatically chooses colors and line styles in the order specified by ColorOrder and LineStyleOrder properties of current axes. MATLAB supports four line styles, which you can specify any number of times in any order. MATLAB cycles through the line styles only after using all colors defined by the ColorOrder property. For example, the first eight lines plotted use the different colors defined by ColorOrder with the first line style. MATLAB then cycles through the colors again, using the second line style specified, and so on.
So you want to do something like:
set(gca, 'ColorOrder', myColorOrder, 'NextPlot', 'replacechildren');
where myColorOrder is an N by 3 array of your custom colors. See my demo for setting ColorOrder here: http://www.mathworks.com/matlabcentral/answers/19815-explicitly-specifying-line-colors-when-plotting-a-matrix

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by