1
$\begingroup$

I have considered 12 major colours to design my custom colour function.

colors = {Black, Blue, Purple, Red, Brown, Gray, Green, Orange, Pink, 
   Cyan, Yellow, White};

I've sorted them based on their corresponding grey values using the formula: value = 0.2989 * Red + 0.5870 * Green + 0.1140 * Blue

and I have got the corresponding values:

positions = {0.0000, 0.1140, 0.20645, 0.2989, 0.43694, 0.50000, 
   0.5870, 0.5924, 0.6494, 0.7010, 0.8859, 1.0000};

When I plot the colour values as a density plot, I get the following

enter image description here

But I want to use the positions as well to get the 12 colours at those positions in a 0 to 1 scale and the rest of the values should get interpolated accordingly.

How can I do this?

$\endgroup$

closed as off-topic by J. M. will be back soon Apr 5 '17 at 4:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Have you noticed Blend? $\endgroup$ – Johu Feb 17 '17 at 13:21
  • $\begingroup$ Does this helps: Plot[Sin[x], {x, -Pi, +Pi}, PlotStyle -> Directive[Orange, Thick, Dashed], ColorFunction -> (Blend[colors, #] &)] $\endgroup$ – mrz Feb 17 '17 at 13:38
4
$\begingroup$

Blend

enter image description here

colors = 
 {Black, Blue, Purple, Red, Brown, Gray, Green, Orange, Pink, Cyan, Yellow, White};

w = List @@@ ColorConvert[colors, "RGB"] . {0.2989, 0.5870, 0.1140}

colorfn = Evaluate[Blend[{w, colors}\[Transpose], #]] &;

DensityPlot[x, {x, 0, 1}, {y, 0, 1}, AspectRatio -> 0.1, ColorFunction -> colorfn]

enter image description here

By the way this question may be of tangential interest:

$\endgroup$

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