Skip to main content

graphics - 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]


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:


ListDensityPlot[data2]

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?




Answer



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.


Comments