Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Hi I want to get a blend similar to "SunsetColors". To make those slight modifications, I would like to know the precise blend of that color scheme.

My try:

Graphics[Table[{Blend[{Black, RGBColor[0.30, 0, 0.36], 
                       RGBColor[.99, .42, 0], LightYellow}, Sqrt[x]], 
                Disk[{8 x, 0}]}, {x, 0, 1, 1/8}]]

And this is how "SunsetColors" looks like:

Graphics[Table[{Blend["SunsetColors", x], Disk[{8 x, 0}]}, {x, 0, 1, 1/8}]]
share|improve this question

2 Answers 2

It looks like the blend colours can be extracted with:

DataPaclets`ColorDataDump`getColorSchemeData["SunsetColors"][[5]]

(* {RGBColor[0., 0., 0.], RGBColor[0.372793, 0.1358, 0.506503], 
 RGBColor[0.788287, 0.259816, 0.270778], 
 RGBColor[0.979377, 0.451467, 0.0511329], 
 RGBColor[1., 0.682688, 0.129771], RGBColor[1., 0.882236, 0.491094], 
 RGBColor[1., 1., 1.]} *)
share|improve this answer
8  
Related chat log: Internal ColorData functions - J. M. & Mr.Wizard –  Mr.Wizard Aug 15 '13 at 15:12
    
@Mr.Wizard, thanks for that, I didn't know you could "Reverse" a colour scheme like that. –  Simon Woods Aug 15 '13 at 15:27

First answer

Ok, Simon Woods killed the fun but I was already wiriting this:

spec = List @@@ Table[ ColorData["SunsetColors", i]
                       , {i, 0, 1, .001}] // Transpose;

ListLinePlot[spec, ImageSize -> 900, PlotStyle -> {Red, Green, Blue}, 
                    BaseStyle -> Thick]

enter image description here

Here we can see how colors are changing across 0-1. It is clearly seen that thare are only a couple of base colors, which are annouced by derrivative change. Let's find those colors.

First, the positions:

change = Accumulate @ (Length /@ 
        (Round[#, 0.000001] & /@ (Subtract @@@ Partition[spec[[3]], 2, 1]) // Split))
(*not very elegant way to find breaks but I'm in hurry*)
{166, 167, 333, 334, 500, 666, 667, 833, 834, 1000}

No need to do this automaticaly so at the end I left:

change = {0, 166, 333, 500, 666, 833, 1000}

And those are our colours:

colors = Blend["SunsetColors", #] & /@ (change/1000)
{RGBColor[0., 0., 0.], RGBColor[0.371302, 0.135257, 0.504477], 
   RGBColor[0.787456, 0.259568, 0.271249], 
   RGBColor[0.979377, 0.451467, 0.0511329], 
   RGBColor[0.999918, 0.681763, 0.129456], 
   RGBColor[1., 0.881837, 0.490371], RGBColor[1., 1., 1.]}
GraphicsGrid[{
          {Graphics[Table[{Blend[colors, x], Disk[{8 x, 0}]}, {x, 0, 1, 1/50}]]}, 
          {Graphics[Table[{Blend["SunsetColors", x], Disk[{8 x, 0}]}, {x, 0, 1, 1/50}]]
             }}, ImageSize -> 900]

enter image description here

Update

Like I've said in comments I think all available color schemes are created via Blend so we do not have to worry about "positions" of each one in color list but the only question is, how many colors are used for each scheme? Then we can take base as sample of equally spaced colors. To prove I'm right:

col = ColorData["Gradients"];

test = {};
Do[
   palette = col[[i]];
   (*following procedure is counting how many lines create given spectrum,
     like in the picture*)
   n = Fold[#2@# &,
            palette,
            {(List @@@ Table[Blend[#, i], {i, 0, 1, .001}])[[;; , 2]] &,
             Round[Differences@#, 10^-6] &,
             Split,
             Length /@ # &,
             Select[#, # > 10 &] &,
             Length
             }];
   basecolors = Blend[palette, #] & /@ Range[0, 1, 1/n]; (*our predictions*)
   realbase = DataPaclets`ColorDataDump`getColorSchemeData[palette][[5]];
   (*real base colors*)
   AppendTo[test, realbase == basecolors]; (*test*)
   , {i, Length@col}];

 test

{True, True, True, True, True, True, True, True, True, False, True, \ True, True, True, True, False, True, True, True, True, True, True, \ True, True, True, True, True, True, True, True, True, False, True, \ True, True, True, True, True, True, True, True, True, True, True, \ True, True, True, True, True, True, True}

There are couple  of Falses, it is because sometimes slopes are so similar that above naive procedure is not able to distinguish them and we end up with underestimated number of lines.

Also if we choose other color to look for lines (*here it is Green, it is set there: [[;; , 2]] *) procedure will fail somewhere else, that's reasonable, it is all because of poor implementation :)

But the point is, my anticipation was correct.

share|improve this answer
    
Very nice. Perhaps you could add a smooth-curve version of the blend as well? That might be interesting. –  Mr.Wizard Aug 15 '13 at 15:02
    
@Mr.Wizard What do you mean? ;) O-C graph between "SunsetColors" and colors? –  Kuba Aug 15 '13 at 15:04
    
If the RGB curves were smoothly interpolated it might be interesting to see how the resulting gradient looked beside the built-in one. –  Mr.Wizard Aug 15 '13 at 15:06
    
@Mr.Wizard I must say, I don't know what you are asking for. Is higher order interpolation important or relevant somehow? Feel free to edit my answer and add this, this will be faster :) –  Kuba Aug 15 '13 at 15:11
    
Never mind; I was just having fun with this. Like I said, nice answer. –  Mr.Wizard Aug 15 '13 at 15:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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