I am making some density and contour plots in Mathematica. These plots have very high peaks which saturate with color and prevent me from seeing differences in the peaks. Is there a way I can tone down the color scale so my peaks are not just white blobs?

Trying other color schemes has not worked out, and playing with the range of color data has not been very useful. Is there some way to have the colors on a log scale???

Here is my code.

ListDensityPlot[photo, PlotLegends -> Automatic, Frame -> {True}, 
FrameLabel -> {"Electron Bunch Energy (MeV)", "Photon Energy (keV)", 
"", "Yield (Photons/Sr e-KeV)" }, LabelStyle -> {15}, 
InterpolationOrder -> 10]

enter image description here

Cheers, Ben

  • 1
    $\begingroup$ Have you tried ColorFunctionScaling -> False ? $\endgroup$
    – Artes
    Aug 22, 2013 at 21:58
  • 2
    $\begingroup$ How about plotting Log[photo] instead? $\endgroup$
    – user484
    Aug 22, 2013 at 21:59
  • 1
    $\begingroup$ Welcome, Ben. I have added your image. I would be very helpful if you could include the photo data or something smaller that is representative. $\endgroup$
    – Mr.Wizard
    Aug 22, 2013 at 22:11
  • $\begingroup$ photo is a table of data with 3 columns, taking log[photo] does not work well, but maybe if I could just take the log of the third column. Any thought on how to do this? (I am very new to mathematica) $\endgroup$ Aug 22, 2013 at 22:18
  • 1
    $\begingroup$ {#, #2, Log@#3} & @@@ data or MapAt[Log, data, {All, 3}] $\endgroup$
    – Kuba
    Aug 22, 2013 at 22:37

3 Answers 3


It's difficult to help without photo data, but I'm almost sure that PlotRange can solve your problem. Try to control Z coordinate in PlotRange as in this example, to find a better range to your plot.


enter image description here

  • $\begingroup$ This is very helpful but by limiting my plotting range I would be losing information. But, I appreciate the thought! $\endgroup$ Aug 22, 2013 at 23:05
  • 1
    $\begingroup$ You are not limiting you are extending for beyond the saturation zone. :) $\endgroup$
    – Murta
    Aug 22, 2013 at 23:24
  • $\begingroup$ This worked out very well, I was able to make some excellent plots! Any thoughts on how to get rid of the the discontinuous nature and extrapolate the plot? $\endgroup$ Aug 23, 2013 at 2:47
  • $\begingroup$ I'm glad that it has helped you! Maybe in PlotRange->{All,All,{0,1}} you can make it more generic using PlotRange->{All,All,{0,Max[photo[[All,3]]]}}. $\endgroup$
    – Murta
    Aug 23, 2013 at 3:05
  • $\begingroup$ As @Kuba suggests PlotRange->All is much more elegant. See if it works for you. There are some cases that it's necessary to specify manually. $\endgroup$
    – Murta
    Aug 23, 2013 at 14:21

Borrowing Murta's data we can also try out Rahul Narain's Log recommendation:

data = Table[Exp[-10 (x^2 + y^2)], {x, -1, 1, 0.02}, {y, -1, 1, 0.02}];


ListDensityPlot[Log @ data]

enter image description here enter image description here

If your data is in the (x,y,z) form you will need something like {#, #2, Log@#3} & @@@ data as Kuba comments above.


Sorry for the delay but I had net gap.

I wanted to write that sometimes Mathematica is doing things we are not expecting in order to do them fast for example.

It seems in this case default ColorFunctionScalling is not so bad, it's just the issue of not all is plotted.

Sometimes it is also useful to choose more colorful palette:

data = Table[{x, y, 10^6 Exp[-10 (x^2 + y^2)]}, {x, -1, 1, 0.02}, {y, -1, 1, 0.02}
            ] // Flatten[#, 1] &;

SetOptions[ListDensityPlot, ImageSize -> 250]

   ListDensityPlot[data, PlotRange -> All],
   ListDensityPlot[data, PlotRange -> All, ColorFunction -> "Rainbow"]

So basicaly it is what @Murta showed but without checking the range.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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