Rob*_*ter 21 plot wolfram-mathematica
(注意:此问题的所有答案均适用于版本10之前的Mathematica版本.对于版本10及更高版本,请参阅https://mathematica.stackexchange.com/questions/54486/how-to-access-new-colour- scheme-in-version-10和https://mathematica.stackexchange.com/questions/54629/what-are-the-standard-colors-for-plots-in-mathematica-10.)
在Mathematica中使用Plot或ListPlot命令时,会选择某些默认颜色.
出于某些报告中的一致性原因,我想将它们与PlotStyle选项一起使用.事实证明,我无法使用预定义的颜色名称重现默认颜色,尽管蓝色和紫色似乎在某种程度上接近.
因此我的问题是:
如何选择Mathematica在绘图中使用的标准颜色以及PlotStyle?
先感谢您.
belisarius和Sjoerd给出了很好的答案,我们可以从中得出结论
绘图[Sin [x],{x,0,2 Pi},PlotStyle - > ColorData [1,4]]
将导致以第四种标准颜色绘制的正弦值,一些漂亮的绿色.
Eli*_*sey 19
我知道这是真的太迟了,但所用的表达产生了n个颜色ColorData[1]是:
Hue[FractionalPart[0.67 + 2.0 (i - 1)/GoldenRatio], 0.6, 0.6]
Run Code Online (Sandbox Code Playgroud)
更新根据Alexey的评论,您可以使用以下方法找到:
ColorData[1] // InputForm
Run Code Online (Sandbox Code Playgroud)
Sjo*_*ies 16
Plot使用的颜色是ColorData[1].
相比
Graphics[MapIndexed[{#1,
Tooltip[Rectangle[{#2[[1]], 0}, {#2[[1]] + 1, 1}], #1]} &,
ColorData[1] /@ Range[40]]]
Run Code Online (Sandbox Code Playgroud)

与Belisarius的颜色
Graphics[MapIndexed[{#1,
Tooltip[Rectangle[{#2[[1]], 0}, {#2[[1]] + 1, 1}], #1]} &,
Cases[ListPlot[Table[{i}, {i, 40}]], Hue[x__], Infinity]]]
Run Code Online (Sandbox Code Playgroud)

它们是相同的,除了一个是Hue术语或另一个是术语或RGBColor
Dr.*_*ius 12
如果你这样做:
ListPlot[Table[{i}, {i, 10}]] // FullForm
Run Code Online (Sandbox Code Playgroud)
你得到了前10个色调.
或者这为您提供了一个可以使用的列表:
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]}
Run Code Online (Sandbox Code Playgroud)
使用范例:
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}]]
Run Code Online (Sandbox Code Playgroud)

如果您更喜欢RGB色彩空间,您可以这样做:
rgbs= ColorConvert[#, "RGB"] & /@ hues
Run Code Online (Sandbox Code Playgroud)
**编辑**与Eli的公式比较:
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} *)
Run Code Online (Sandbox Code Playgroud)
太好了,Eli!