Skip to main content

plotting - Define a color function based on color samples obtained from ColorBrewer


I am quite new to Mathematica and I am searching for a way to create a smooth colormap based on the samples given by ColorBrewer. Is it possible to create a interpolated function from those sample points?



Answer



I enter RGB values in a matrix using Ctrl+, and Ctrl+Enter (tutorial):


Mathematica graphics



{{237, 248, 177}, {127, 205, 187}, {44, 127, 184}}

Then create a color function cf:



With[{rgb = RGBColor @@@ (dat/255)},
cf = Blend[rgb, #] &;
]

And use it:


ArrayPlot[{Range@10}, ColorFunction -> cf]

Mathematica graphics


ListPlot3D[
Table[Sin[j^2 + i], {i, 0, Pi, Pi/5}, {j, 0, Pi, Pi/5}],

Mesh -> None,
InterpolationOrder -> 0,
ColorFunction -> cf
]

Mathematica graphics


Comments