7

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
matheorem
  • 17,132
  • 8
  • 45
  • 115

2 Answers2

10

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

C. E.
  • 70,533
  • 6
  • 140
  • 264
6

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574