0
$\begingroup$

I'd like to get a colour scheme gradient (e.g. ColorData["TemperatureMap"]), split the domain into n equidistant points, and then recover the colour codes (RGB or Hex) for the resulting n points.

$\endgroup$
  • $\begingroup$ Take a look at Blend. $\endgroup$ – Kuba Mar 17 '16 at 14:11
  • 1
    $\begingroup$ And the documentation for ColorData, especially the properties. $\endgroup$ – Brett Champion Mar 17 '16 at 14:21
2
$\begingroup$
Clear[g]
g[color_, n_] := 
 Table[ColorData[color][i], {i, 0, ColorData[color][[3, 2]], 1/n}]
List @@@ g["TemperatureMap", 10]

(*{{0.178927, 0.305394, 0.933501}, {0.33766, 0.466886, 
  0.942736}, {0.528934, 0.628452, 0.956059}, {0.748934, 0.803792, 
  0.97561}, {0.912556, 0.933111, 0.991522}, {0.984192, 0.987731, 
  0.911643}, {0.994726, 0.991128, 0.667358}, {0.977887, 0.93707, 
  0.368596}, {0.924921, 0.740045, 0.258448}, {0.867569, 0.491545, 
  0.211209}, {0.817319, 0.134127, 0.164218}}*)
$\endgroup$
  • $\begingroup$ Browsing this site, it seems the goal is always to avoid using Table. In that spirit, this does the same thing: List @@@ ColorData["TemperatureMap"] /@ Subdivide[1, 10] $\endgroup$ – Jason B. Mar 17 '16 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.