7
$\begingroup$

Origin is a software for plotting.

The standard color scheme used by Origin is

Origin colormap

So how do I mimic this color scheme in Mathematica, so that we can use it in DensityPlot to achieve the same appearance that will be produced by Origin?


edit

C. E. already provided a color bar that resembles the one in Origin.

To use it in ListDensityPlot, there is one more step needed to specify the ColorFunction properly:

DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}, 
 ColorFunction -> (Hue[1 - (2 #/3 + 1/3)] &), 
 PlotLegends -> Automatic, PlotPoints -> 50]

Notice that I use 1/3, because in Origin, the color runs from blue to red. Red corresponds to Hue[1] and blue corresponds to Hue[1/3]. This can be seen from ColorConvert[Hue[1/3], RGBColor] // FullForm. (Thanks to J.M. for letting me know about ColorConvert)

The above code gives

density plot

$\endgroup$
  • $\begingroup$ It's very similar to Hue: BarLegend[{Hue[1 - #] &, {0.3, 1}}] $\endgroup$ – C. E. Dec 5 '15 at 16:27
  • $\begingroup$ @Pickett Bravo! indeed. Make it answer? or is it a duplicate? or just too trivial : ) $\endgroup$ – matheorem Dec 5 '15 at 16:34
  • $\begingroup$ Have a look at BarLegend[{Hue[2 (1 - Rescale[#, {-1, 1}])/3] &, {-1, 1}}]. $\endgroup$ – J. M. is away Dec 10 '15 at 5:00
  • $\begingroup$ @J.M. Thank you. A question: How to know the RGB values of for example Hue[0.33]? $\endgroup$ – matheorem Dec 10 '15 at 5:43
  • $\begingroup$ You can use ColorConvert[] to convert colors in any other format to RGB; e.g. ColorConvert[Hue[1/3], RGBColor]. $\endgroup$ – J. M. is away Dec 10 '15 at 6:07
10
$\begingroup$

It is basically a reversed Hue that's been clipped off. In the image to the left below you see all of the values of Hue next to one that I cut off by picking a value (0.3) that seemed right. That value could be calculated more rigorously by looking at the color peaks and the distances between them in the Origin bar legend.

Row[{
  BarLegend[{Hue[1 - #] &, {0, 1}}],
  BarLegend[{Hue[1 - #] &, {0.3, 1}}]
  }]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Since Hue[2/3] is actually Blue after RGB conversion, your second line should be something like BarLegend[{Hue[2 (1 - #)/3] &, {0, 1}}]. $\endgroup$ – J. M. is away Dec 10 '15 at 4:58
5
$\begingroup$

By request:

Altho I prefer the Hue[] formulation:

originColorFunction = Hue[2 (1 - #)/3] &;

one can also choose to implement this in terms of Blend[]:

originColorFunction2 = Blend[{Blue, Cyan, Green, Yellow, Red}, #] &;

To see why this works, recall that in the HSB system, the color cycle proceeds in the sequence Red, Yellow, Green, Cyan, Blue, Magenta, and finally back to Red, with linear interpolation of colors in between:

ColorConvert[Hue /@ (Range[0, 5]/6), RGBColor]
   {RGBColor[1., 0., 0.], RGBColor[1., 1., 0.], RGBColor[0., 1., 0.],
    RGBColor[0., 1., 1.], RGBColor[0., 0., 1.], RGBColor[1., 0., 1.]}

and since the Origin color function has Magenta dropped, as well as the colors being reversed, the simple linear interpolation with Blend[] will produce the exact same color sequence.

$\endgroup$
  • $\begingroup$ (N.B. this is also the color scheme used by the DLMF.) $\endgroup$ – J. M. is away Mar 17 '18 at 13:01

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.