开发者

What are the standard colors for plots in Mathematica?

(Note: All the answers to this question are valid for versions of Mathematica before version 10. For versions 10 and above, see https://mathematica.stackexchange.com/questions/54486/how-to-access-new-colour-schemes-in-version-10 and htt开发者_Python百科ps://mathematica.stackexchange.com/questions/54629/what-are-the-standard-colors-for-plots-in-mathematica-10.)

When using the Plot or ListPlot command in Mathematica, certain default colors are chosen.

For reasons of uniformity within some report I would like to use them along with the PlotStyle option. It turned out that I cannot reproduce the default colors with the pre-defined color names, although blue and purple seem to be somehow close.

Hence my question:

How can I chose the standard colors used by Mathematica in plots along with PlotStyle?

Thank you in advance.

Nice answers were given by belisarius and Sjoerd from which we can conclude that

Plot[Sin[x], {x, 0, 2 Pi}, PlotStyle -> ColorData[1, 4]]

will result in a sine plotted in the fourth standard color, some nice green.


I know this is really late to the game, but the expression used to generate the nth color in ColorData[1] is:

Hue[FractionalPart[0.67 + 2.0 (i - 1)/GoldenRatio], 0.6, 0.6]

Update Based on Alexey's comment below, you can find this using:

ColorData[1] // InputForm


The colors used by Plot are in ColorData[1].

Compare

Graphics[MapIndexed[{#1, 
    Tooltip[Rectangle[{#2[[1]], 0}, {#2[[1]] + 1, 1}], #1]} &, 
  ColorData[1] /@ Range[40]]]

What are the standard colors for plots in Mathematica?

with Belisarius' colors

Graphics[MapIndexed[{#1, 
    Tooltip[Rectangle[{#2[[1]], 0}, {#2[[1]] + 1, 1}], #1]} &, 
  Cases[ListPlot[Table[{i}, {i, 40}]], Hue[x__], Infinity]]]

What are the standard colors for plots in Mathematica?

They are the same, except one is terms of Hue and the other in terms or RGBColor


If you do:

ListPlot[Table[{i}, {i, 10}]] // FullForm  

You get the first 10 Hues used.

Or this gives you a ready to use list:

hues = Cases[ListPlot[Table[{i}, {i, 10}]], Hue[x__], Infinity]

{Hue[0.67, 0.6, 0.6],     Hue[0.906068, 0.6, 0.6], 
 Hue[0.142136, 0.6, 0.6], Hue[0.378204, 0.6, 0.6], 
 Hue[0.614272, 0.6, 0.6], Hue[0.85034, 0.6, 0.6], 
 Hue[0.0864079, 0.6, 0.6],Hue[0.322476, 0.6, 0.6], 
 Hue[0.558544, 0.6, 0.6], Hue[0.794612, 0.6, 0.6]}  

Usage sample:

SphericalPlot3D[\[Phi], {\[Theta], 0, Pi}, {\[Phi], 0, 3 Pi},
 Epilog -> 
  Table[Inset[Framed[Style["Spiral", 20],
        Background -> hues[[i]]],
             {i/15 + .1, i/15}], 
  {i, 10}]]  

What are the standard colors for plots in Mathematica?

If you prefer the RGB color space you may do:

rgbs= ColorConvert[#, "RGB"] & /@ hues

**Edit ** Comparing with Eli's formula:

mine = Cases[ListPlot[Table[{i}, {i, 10}]], Hue[x__], Infinity]
elis = Table[Hue[FractionalPart[0.67 + 2.0 (i-1)/GoldenRatio],0.6,0.6], {i,1,10}]
Chop[(mine- elis) /. Hue[x_, __] -> x]
(* -> {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} *)

Great, Eli!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜