FAQ
overflow

Great Answers to
Questions About Everything

QUESTION

As sophomoric as this question seems, how should I save plots in grayscale in Mathematica?

I generally like eps images for their scalability and I use ghostscript or other third party perl scripts to convert my images to grayscale.

{ asked by drN }

ANSWER

One way would be to use ColorConvert to convert the RGB or Hue values to gray scale. Here's an example:

Plot[{Sin[x], Cos[x], Exp[-x^2], Sinc[π x]}, {x, 0, π}] /. 
  x : _RGBColor | _Hue | _CMYKColor :> ColorConvert[x, "Grayscale"]

For 2D plots that accept a ColorFunction, you can simply use GrayLevel to get the plot in grayscale as:

DensityPlot[
  Sin[x ^2 + y^2], {x, 0, 3}, {y, 0, 3},
  ColorFunction -> GrayLevel,
  PlotPoints -> 100
]


Typically, these grayscale plots are useful when submitting to journals that charge exorbitant prices just to print in colour. However, just a note of caution that discerning different shades of gray is not easy. For the most effect, it is recommended (at least in the journals I publish in), that you also change the line type for your different curves (and not more than 4 curves/plot). You should also choose the colours (or colourscale, for 2D surface plots) wisely so that they convert well to grayscale. For example:

{ answered by rm -rf }
Tweet