Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with ListDensityPlot. I have some data on an irregular grid.

I try to plot them with

ListDensityPlot[data,PlotRange -> {{xStart, xEnd}, {yStart, yEnd}}, FrameTicks -> True, 
AspectRatio -> Abs[(yEnd - yStart)/(xEnd - xStart)], PlotRangePadding -> None,   
ColorFunction -> (If[#1 === 0 , Black, GrayLevel[Rescale[#1, {0, 1}]]] &), 
ColorFunctionScaling -> False, LightingAngle -> None, InterpolationOrder -> 0, ImageSize -> 1000]

In the output I have some ugly white spots: picture with white spots

If I change my plot (setting xEnd = 230), the white spots disappear: picture with reduced range

So, from my point of view, the white spots are not caused by my data. Somehow Mathematica (I am using 9.0.1) causes them.

To solve this problem I am using the following workaround:

ListPlot3D[data, PlotRange -> {{xStart, xEnd/1}, {yStart, yEnd}, All}, 
BoxRatios -> {1, Abs[(yEnd - yStart)/(xEnd - xStart)], 1}, 
ColorFunction -> (If[#1 === 0 , Black, GrayLevel[Rescale[#3, {0, 1}]]] &), 
ColorFunctionScaling -> True,Mesh -> None, ImageSize -> 1500, 
ViewPoint -> {0, 0, Infinity}, InterpolationOrder -> 0, BoundaryStyle -> None]

This gives me a nice output: picture without white spots

What can I do that I get the same output with ListDensityPlot? At least I need ListDensityPlot because changes in the InterpolationOrder look there different than in the ListPlot3D.

There is perhaps a similar question here, but rescaling does not help here. Additionally, my problem is “solved” with ListPlot3D, Eli Lansey’s problem not.

I would be happy about some help!

share|improve this question
Looks like it might be clipping. Try PlotRange -> {{xStart, xEnd}, {yStart, yEnd}, All} – Michael E2 Jun 13 '13 at 14:30
1000 scores for you!! This is the solution! Please type this as answer, so that I can give you at least one score! How shall somebody have the idea to use 3 options in PlotRange for a 2-dimensional plot? As far as I know there is nothing about this trick in the help about ListDensityPlot. Anyway, thanks a lot! – partial81 Jun 13 '13 at 14:47
up vote 5 down vote accepted

The white generally indicates plot range clipping. See ListDensityPlot, the ClippingStyle and PlotRange sections.


PlotRange -> {{xStart, xEnd}, {yStart, yEnd}, All}

will include all data values. If the data has a few extreme values, including the whole range will flatten out smaller variations in the data.

share|improve this answer
Thanks again for this solution. I know ClippingStyle, but that you can get rid of this feature by your trick is new for me. Actually, this trick should be mentioned in Mathematica`s help (or I have overseen it). Anyway, you helped me a lot! – partial81 Jun 13 '13 at 15:27
@partial81 I think the examples in the "PlotRange" section (under "Options") of ListDensityPlot is trying to show this trick. I admit that at first glance, it's hard to see because the default color scheme ends at "white." Try them with ColorFunction -> "Rainbow". (Also I mistyped the link in my answer -- fixed now.) – Michael E2 Jun 13 '13 at 16:00
You are right! And this trick is well hidden. Thanks for the fix and the explanation! – partial81 Jun 13 '13 at 16:17

Your Answer


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.