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!

  • 2
    $\begingroup$ Looks like it might be clipping. Try PlotRange -> {{xStart, xEnd}, {yStart, yEnd}, All} $\endgroup$
    – Michael E2
    Jun 13, 2013 at 14:30
  • $\begingroup$ 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! $\endgroup$
    – partial81
    Jun 13, 2013 at 14:47
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/14260/… $\endgroup$
    – Michael E2
    May 15, 2021 at 14:46

1 Answer 1


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.

  • $\begingroup$ 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! $\endgroup$
    – partial81
    Jun 13, 2013 at 15:27
  • $\begingroup$ @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.) $\endgroup$
    – Michael E2
    Jun 13, 2013 at 16:00
  • $\begingroup$ You are right! And this trick is well hidden. Thanks for the fix and the explanation! $\endgroup$
    – partial81
    Jun 13, 2013 at 16:17

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.