ColorData
更多信息
- ColorData["scheme"][par] 或 ColorData["scheme",par] 给出指定颜色方案中对应于参数值 par 的 RGBColor 对象.
- 标准方案集合包括:
-
"Gradients" 归一化的连续颜色梯度 "Indexed" 用连续整数索引的颜色 "Named" 命名颜色的集合 "Physical" 物理参数确定的颜色 - 默认情况下,颜色梯度有一个范围从0到1的单一参数.
- ColorData[{"gradient","Reverse"}] 给出范围在0和1之间的颜色梯度,其中对颜色的逆向排序.
- ColorData[{"gradient",{min,max}}] 给出范围在 min 和 max 之间的颜色梯度.
- ColorData[n,…] 使用第 n
个索引的调色板. - ColorData["scheme","property"] 中可能的属性包括:
-
"ColorFunction" 应用于参数的颜色函数 "ColorList" 有限个索引颜色方案的颜色列表 "ColorRules" 具体方案的颜色规则 "Image" 显示方案颜色的图形 "Name" 颜色方案的英文名称 "Panel" 显示方案颜色的一个可点击的面板 "ParameterCount" 用于方案的参数的数量 "Range" 第一个参数的范围 {"Range",i} 第
个参数的范围 - 设置在滑尺上的范围:
-
{xmin,xmax} xmin 到 xmax 的持续值 {xmin,xmax,dx} 步长 dx 的离散值 {{x1,x2,…}} 具体离散值 - ColorData["DefaultPlotColors"] 给出如函数 Plot 和 ListPlot 使用的默认颜色序列.
- ColorData["DefaultChartColors"] 给出如 PieChart 和 BarChart 这样的函数使用的默认颜色序列.
- ColorData["scheme"] 给出一个 ColorDataFunction 对象.
范例
打开所有单元 关闭所有单元基本范例 (5)
ColorData["TemperatureMap"]Plot3D[Exp[-x ^ 2 - y ^ 2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (ColorData["TemperatureMap"][#3]&)]Plot3D[Exp[-x ^ 2 - y ^ 2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (ColorData[{"TemperatureMap", "Reverse"}][#3]&)]Plot[Evaluate[Table[Sin[x + Pi n / 4], {n, 0, 7}]], {x, 0, 2Pi}, Filling -> Axis, PlotStyle -> ColorData[3, "ColorList"]]ContourPlot[x + Sin[x ^ 2 + y ^ 2], {x, -4, 4}, {y, -4, 4}, Contours -> 9, ContourShading -> ColorData[35, "ColorList"]]范围 (23)
方案和集合 (6)
ColorData[]Short[ColorData["Gradients"]]Short[ColorData["Indexed"]]ColorData["Named"]ColorData["Physical"]梯度是一个连续颜色函数,它适用于 ColorFunction:
DensityPlot[y + Sin[x ^ 2 + 3y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> ColorData["SunsetColors"]]ColorData[{"gradient","Reverse"}] 返回具有相反颜色顺序的梯度颜色函数:
DensityPlot[y + Sin[x ^ 2 + 3y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> ColorData[{"SunsetColors", "Reverse"}]]Short[ColorData[3, "ColorList"], 4]data = Table[RandomReal[{2i, 2 i + 1}, {20}], {i, 7}];ListLinePlot[data, PlotStyle -> ColorData[3, "ColorList"], InterpolationOrder -> 2]Graphics[{ColorData["HTML", "Violet"], Disk[], ColorData["HTML", "MidnightBlue"], Disk[{1, 0}]}]DensityPlot[x, {x, 380, 750}, {y, 0, 50}, ColorFunction -> ColorData["VisibleSpectrum"], ColorFunctionScaling -> False, AspectRatio -> Automatic, PlotRangePadding -> 10, FrameTicks -> {{None, None}, {Automatic, None}}]属性 (10)
ColorData["Properties"]"ColorFunction" 返回 ColorDataFunction 对象:
ColorData["SouthwestColors", "ColorFunction"]ColorData[38, "ColorList"]Short[ColorData["Atoms", "ColorList"]]ColorData["PlumColors", "ColorList"]ColorData[42, "ColorRules"]Short[ColorData["Legacy", "ColorRules"], 3]ColorData["DarkRainbow", "Image"]ColorData[22, "Image"]ColorData["HTML", "Image"]ColorData["VisibleSpectrum", "Image"]ColorData["HTML", "Name"]ColorData["SunsetColors", "Panel"]ColorData[17, "Panel"]ColorData["GeologicAges", "Panel"]ColorData["BlackBodySpectrum", "Panel"]ColorData["AuroraColors", "ParameterCount"]ColorData["GrayYellowTones", "Range"]ColorData[12, "Range"]Short[ColorData["HTML", "Range"]]ColorData["VisibleSpectrum", "Range"]取值范围可以直接用于控制组件中,例如 Slider:
{Slider[Dynamic[w], ColorData["GrayYellowTones", "Range"]], Dynamic[w]}{Slider[Dynamic[x], ColorData[12, "Range"]], Dynamic[x]}{Slider[Dynamic[y], ColorData["HTML", "Range"]], Dynamic[y]}{Slider[Dynamic[z], ColorData["VisibleSpectrum", "Range"]], Dynamic[z]}属性值 (7)
ColorData["HypsometricTints", "Image"]Take[ColorData[37, "ColorRules"], 3]ColorData["SouthwestColors", 0.5]每个方案返回一个 ColorDataFunction 对象:
ColorData["GrayYellowTones"]ColorData[12]ColorData["HTML"]ColorData["VisibleSpectrum"]当应用的值在一个特定的范围内时,ColorDataFunction 返回 RGB 颜色:
ColorData["GrayYellowTones"][.5]
%//InputFormColorData[12][7]
%//InputFormColorData["HTML"]["WhiteSmoke"]
%//InputFormColorData["VisibleSpectrum"][550]
%//InputFormColorData["GrayYellowTones", "Range"]ColorData["VisibleSpectrum", "Range"]ColorData[12, "Range"]一个索引的范围可以返回一个应用 Range 的列表:
Apply[Range, %]Short[ColorData["HTML", "Range"]]不适用的属性返回 Missing["NotApplicable"]:
ColorData["SouthwestColors", "ColorList"]ColorData["SouthwestColors", "ColorRules"]推广和延伸 (2)
应用 (9)
dem = Import["http://exampledata.wolfram.com/hailey.dem.gz", "Data"];ReliefPlot[dem, MaxPlotPoints -> 300, ColorFunction -> ColorData["BrightBands"]]Graphics[{EdgeForm[{StandardGray, Opacity[.5]}], With[{p = QuantityMagnitude[CountryData[#, "Population"]]}, {If[NumberQ[p], ColorData["SolarColors"][1. - p 10 ^ -9], White], CountryData[#, {"SchematicPolygon", "Robinson"}]}]& /@ CountryData[]}, PlotRange -> Automatic]用 Directive 混合使用 ColorData 中的各种表面属性:
Plot3D[Evaluate[ D[(x^2 + y^2) Exp[1 - x^2 - y^2], y]], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (Directive[Opacity[#3], ColorData["ThermometerColors"][#3]]&), PlotRange -> All, Mesh -> None]在 ContourShading 中用索引方案的颜色列表:
ContourPlot[Sin[x]Sin[y], {x, -0, 3Pi}, {y, 0, 3Pi}, ContourShading -> ColorData[8, "ColorList"], FrameTicks -> False]在 MeshShading 中应用一个划分的颜色列表:
ParametricPlot3D[{(2 + Cos[v])Cos[u], (2 + Cos[v])Sin[u], Sin[v]}, {u, 0, 2Pi}, {v, 0, 2Pi}, Mesh -> 15, Lighting -> "Neutral", MeshShading -> Partition[ColorData[9, "ColorList"], 2]]Grid[{{a, b, c}, {d, e, f}, {g, h, i}}, Frame -> All, Background -> {{"LightSteelBlue", "Salmon", "PaleGreen"}}] /. ColorData["HTML", "ColorRules"]在 ArrayPlot 中使用颜色名称及颜色规则:
w = Partition[First@ColorData["WebSafe", "Range"], 12];Short[w, 3]ArrayPlot[w, ColorRules -> ColorData["WebSafe", "ColorRules"]]Graphics3D[{Specularity[White, 50], ColorData["Atoms", "H"], Sphere[{0, 0, 0}, .7], Sphere[{1.4, 0, 0}, .7], ColorData["Atoms", "O"], Sphere[{.7, 0, .7}]}, Lighting -> "Neutral"]Blackbody[T_] := With[{h = 6.6262 10 ^ -34, c = 2.99792458 10 ^ 8, k = 1.3807 10 ^ -23}, Plot[(2h c ^ 2 / λ ^ 5 ) / (Exp[h c / (λ k T)] - 1), {λ, 10 ^ -9, 1000 10 ^ -9}, MaxRecursion -> 0, ColorFunction -> (ColorData["VisibleSpectrum"][10 ^ 9#]&), ColorFunctionScaling -> False, Filling -> Axis, Ticks -> None, PlotLabel -> Row[{T, " K"}]]]Row[Table[Blackbody[t], {t, {2000, 4000, 6000, 8000}}], Spacer[2]]Graphics[{EdgeForm[Gray], Table[{ColorData["BlackBodySpectrum", 1000 t], Text[1000t"K", {2t, 1.5}, {-1, 0}, {0, 1}], Disk[{2t, 0}, .9]}, {t, 10}]}]属性和关系 (5)
只有在 ColorFunction 中才能用它们的名称来指代相关的梯度:
DensityPlot[Sin[x]Sin[y], {x, -4, 4}, {y, -3, 3}, ColorFunction -> "AvocadoColors"]DensityPlot[x, {x, -1, 2}, {y, 0, 1}, ColorFunction -> ColorData["SunsetColors"], ColorFunctionScaling -> False]DensityPlot[x, {x, 300, 800}, {y, 0, 1}, ColorFunction -> ColorData["VisibleSpectrum"], ColorFunctionScaling -> False]ArrayPlot[{Range[40]}, ColorFunction -> ColorData[10], ColorFunctionScaling -> False, AspectRatio -> .3]ColorData[10][2]//InputFormColorData[10][2.5]//InputForm对于元素颜色,ChemicalData 使用 ColorData["Atoms"]:
ChemicalData["Benzthiazuron", "MoleculePlot"]ChemicalData["Benzthiazuron", "HillFormula"]可能存在的问题 (3)
r = ColorData["HTML", "Range"];Short[r, 4]Dimensions[r]First 可用于名称列表中:
n = First[ColorData["HTML", "Range"]];Short[n, 4]在绘制多重 ColorFunction 槽的图形时,如果没有明确指定,选择第一个槽:
Plot3D[ Exp[1 - x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> ColorData["Rainbow"], PlotRange -> All, Mesh -> None]Plot3D[ Exp[1 - x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][z]], PlotRange -> All, Mesh -> None]Plot3D[ Exp[1 - x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (ColorData["BrightBands"][#3]&), PlotRange -> All, Mesh -> None]增加 PlotPoints 可以减少这类问题::
Plot3D[ Exp[1 - x^2 - y^2], {x, -2, 2}, {y, -2, 2}, ColorFunction -> (ColorData["BrightBands"][#3]&), PlotPoints -> 80, PlotRange -> All, Mesh -> None]巧妙范例 (4)
ReliefPlot[Table[RandomReal[](Sin[x + y ^ 2] + Sin[x ^ 2 + 3y]), {x, -3, 3, .01}, {y, -3, 3, .01}], ColorFunction -> ColorData["SouthwestColors"]]ReliefPlot[Table[Evaluate[Sum[Sin[RandomReal[4, 2].{x, y}], {5}]], {x, 0, 10, .05}, {y, 0, 10, .05}], ColorFunction -> ColorData["Rainbow"]]Grid[Partition[Show[ColorData[#, "Image"], ImageSize -> 110]& /@ ColorData["Gradients"], 4, 4, 1, {}], Spacings -> .5]Grid[Partition[Framed[Show[ColorData[#, "Image"], ImageSize -> 100], FrameStyle -> Gray]& /@ ColorData["Indexed"], 4, 4, 1, {}], Spacings -> .25]文本
Wolfram Research (2007),ColorData,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ColorData.html (更新于 2026 年).
CMS
Wolfram 语言. 2007. "ColorData." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2026. https://reference.wolfram.com/language/ref/ColorData.html.
APA
Wolfram 语言. (2007). ColorData. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ColorData.html 年
BibTeX
@misc{reference.wolfram_2026_colordata, author="Wolfram Research", title="{ColorData}", year="2026", howpublished="\url{https://reference.wolfram.com/language/ref/ColorData.html}", note=[Accessed: 09-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_colordata, organization={Wolfram Research}, title={ColorData}, year={2026}, url={https://reference.wolfram.com/language/ref/ColorData.html}, note=[Accessed: 09-August-2026]}