Consider the following dataset:

data = Flatten[
 Table[{x 10^-9, y 10^-9, x^2 + y^2},{x, -100, 100, 10}, {y, -100,100, 10}]
 , 1];

If I try to ListDensityPlot this set:


Mathematica graphics

it does not plot the function. However, if I do the obvious re-scale of the coordinates:

data2 = Flatten[Table[{x , y , x^2 + y^2}, {x, -100, 100, 10}, {y, -100, 100, 10}], 1];

it has no problem plotting it:


Mathematica graphics

The same problem exists for other plotting methods (ListPlot3D, ListContourPlot, etc.). While rescaling the coordinates is a simple fix, is it possible to plot datasets of this sort without first rescaling the coordinates?

  • $\begingroup$ ListDensityPlot[data] works fine in V12.2. At some point in the last nine years, this must have been fixed. $\endgroup$
    – Michael E2
    May 15, 2021 at 14:50

2 Answers 2


The reason why ListDensityPlot doesn't plot it is because the meshes aren't being generated correctly:

ListDensityPlot[data #, Mesh -> All, ImageSize -> 300] & /@ {1, 100, 10^3, 10^4}

enter image description here

Now I don't know exactly how to fix this, but my guess is that the mesh function relies on the Delaunay triangulation of the set of points and somewhere in there, something is either dangerously close to machine precision or getting Chopped. Since the default tolerance for chopping is $10^{-10}$, it is plausible that this is what is happening.

  • $\begingroup$ Very interesting. Your point about the meshing seems to be correct. The mesh seems to converge to a stable sort of version with scaling here ~10^8. $\endgroup$
    – Eli Lansey
    Apr 18, 2012 at 2:26
  • $\begingroup$ @EliLansey Also, the mesh depends on the order the points in the original data, suggesting that it might be a naïve incremental triangulation. To see what I mean, try ListDensityPlot[RandomSample[data, 441] #, Mesh -> All, ImageSize -> 300] & /@ {1, 100, 10^3, 10^4} $\endgroup$
    – rm -rf
    Apr 18, 2012 at 2:39
  • $\begingroup$ if you add MaxPlotPoints -> 20 then last 2 graphs are fine... and MaxPlotPoints -> 10 then 3rd graph is fine but not 4th. $\endgroup$
    – s.s.o
    Apr 18, 2012 at 4:45
  • $\begingroup$ The ListDensityPlot works with Graphics options and primitives are converted to integer somewhere as you said it chops the data so does the ListPlot3D... And with graphics it has no option for accuracy like some other plots. $\endgroup$
    – s.s.o
    Apr 18, 2012 at 4:52

You should set the

DataRange->{{Subscript[x, min],Subscript[x, max]},{Subscript[y, min],Subscript[y, max]}} 

which specifies other ranges of coordinate values to use. By default it uses the Automatic values... e.g.

ListDensityPlot[data, DataRange -> {{-100, 100}, {-10^-9, 10^-9}}]
  • $\begingroup$ I think you mean DataRange -> {{-10^-7, 10^-7}, {-10^-7, 10^-7}}. This works because using Datarange makes ListDensityPlot completely ignore the x and y values. $\endgroup$ Apr 17, 2012 at 21:07
  • $\begingroup$ I didn't test if the ranges are correct. Just tried to give an example. But it was working. May be you are right. I'll check... $\endgroup$
    – s.s.o
    Apr 17, 2012 at 21:12
  • $\begingroup$ This doesn't work. This is helpful if you have an array of values like Table[x^2 + y^2, {x, -100, 100, 10}, {y, -100, 100, 10}], but here I have the x and y values given. $\endgroup$
    – Eli Lansey
    Apr 17, 2012 at 21:25
  • 1
    $\begingroup$ yep, both of you are right and same problem exist for ListPlot3D too. Some how it's related to precision 10^-5 works but not 10^-9... $\endgroup$
    – s.s.o
    Apr 17, 2012 at 21:35
  • 1
    $\begingroup$ DataRange does not work correctly for this problem on version 7. The plot comes out mangled: i.sstatic.net/Xl5NY.png $\endgroup$
    – Mr.Wizard
    Apr 17, 2012 at 21:53

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.