# Why is ListDensityPlot unable to plot datasets with extreme ranges

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:

ListDensityPlot[data]


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:

ListDensityPlot[data2]


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?

-

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}


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.

-
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. –  Eli Lansey Apr 18 '12 at 2:26
@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} –  rm -rf Apr 18 '12 at 2:39
if you add MaxPlotPoints -> 20 then last 2 graphs are fine... and MaxPlotPoints -> 10 then 3rd graph is fine but not 4th. –  s.s.o Apr 18 '12 at 4:45
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. –  s.s.o Apr 18 '12 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}}]

-
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. –  Sjoerd C. de Vries Apr 17 '12 at 21:07
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... –  s.s.o Apr 17 '12 at 21:12
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. –  Eli Lansey Apr 17 '12 at 21:25
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... –  s.s.o Apr 17 '12 at 21:35
DataRange does not work correctly for this problem on version 7. The plot comes out mangled: i.stack.imgur.com/Xl5NY.png –  Mr.Wizard Apr 17 '12 at 21:53