13
$\begingroup$

Bug introduced in 10.0 and persisting through 11.0.1 or later


It seems that I obtain different results when using ListContourPlot under V9 and V10.

Using this datafile http://pastebin.com/2p4ew0NJ (modified to use pastebin), this code:

ListContourPlot[cm, PlotLegends -> Automatic, Contours -> 18, 
 ContourStyle -> None, PlotRange -> {{0, 13000}, {0, 8}, {0, 0.0007}}]

gives this under V9:

contour plot image

and this under V10:

contour plot image

Colors aside, ListContourPlot behavior under V10 is to always increase the level (or to change the z plot range) when you go above half the horizontal scale (here above x = 6500) -- I verified it with a lot of other data files.

$\endgroup$
  • 1
    $\begingroup$ I remember 4shared not being completely awful, but I couldn't even use it this time. Too many junk links that try to download adware. Try putting it on pastebin maybe? $\endgroup$ – Jason B. Oct 20 '14 at 15:23
  • $\begingroup$ I apparently can't download it without having a 4shared account or connect though "social media" which I'm not willing to. $\endgroup$ – Öskå Oct 20 '14 at 15:27
  • $\begingroup$ modified to pastebin - did it work? $\endgroup$ – alessandro Oct 21 '14 at 11:25
  • $\begingroup$ I can confirm that there's something wrong here. You can reproduce the problem in just version 10 by comparing the output of ListDensityPlot[cm, PlotRange -> {{6566, 13000}, All, {0, 0.0007}}] with ListDensityPlot[cm[[2251 ;;]], PlotRange -> {0, 0.0007}] . These should give the exact same results but they do not. I thought the issue might be the irregular grid you use, but that isn't the problem. $\endgroup$ – Jason B. Oct 21 '14 at 12:13
  • $\begingroup$ Somehow the interpolation algorithm in ListContourPlot and ListDensityPlot is messing up here. As a side note, if you are using ContourStyle->None, why not just use ListDensityPlot? A workaround to get the correct plot is to build up an interpolation function: cmfunc=Interpolation[cm];DensityPlot[cmfunc[x,y],{x,0,13000},{y,0,8.8},PlotRange->{0,.0007},PlotPoints->100] $\endgroup$ – Jason B. Oct 21 '14 at 12:15
10
$\begingroup$

It seems to me that ListDensityPlot connects points incorrectly because of the very big ratio of x- and y-scale. So I propose to rescale the data

data = Import["http://pastebin.com/raw.php?i=2p4ew0NJ", "Table"];
ListDensityPlot[Transpose[Transpose@data/{1000, 1, 1}], PlotLegends -> Automatic, 
 PlotRange -> {{0, 13}, {0, 8}, {0, 0.0007}}]

enter image description here

Then you can rescale back the plot

Show[% /. g_GraphicsComplex :> 
   GeometricTransformation[g, ScalingTransform[{1000, 1}]], 
 PlotRange -> {{0, 13000}, {0, 8}}]

enter image description here

$\endgroup$
  • $\begingroup$ Crazy solution, I like it! $\endgroup$ – shrx Nov 12 '15 at 20:09
8
$\begingroup$

Extended comment

(Update : NOT fixed in v10.3.1)

Here is a minimal example which shows clearly that the problem is the difference of the axis scales even for equally spaced points. It concerns ListDensityPlot and ListContourPlot but also ListPlot3D(see Edit below)

fp[x_, y_] := (x^2 + y^2)

This is the function plot:

ContourPlot[fp[x, y], {x, -1, 1}, {y, -1, 1}]

enter image description here

Now, we take equally spaced points from the surface

n = 20; xyz = Join @@ Table[{x, y, fp[x, y]}, {x, -1., 1., 1./n}, {y, -1, 1., 1./n}];

and now let's change the data scale on one axis only and listplot the new scaled data:

xyz // GraphicsGrid[{{ListContourPlot@#, ListDensityPlot@#}}] &

enter image description here

MapAt[#*10000 &, xyz, {All, 2}] // 
 GraphicsGrid[{{ListContourPlot@#, ListDensityPlot@#}}] &

enter image description here

MapAt[#*30000 &, xyz, {All, 2}] // 
 GraphicsGrid[{{ListContourPlot@#, ListDensityPlot@#}}] &

enter image description here

MapAt[#*100000 &, xyz, {All, 2}] // 
 GraphicsGrid[{{ListContourPlot@#, ListDensityPlot@#}}] &

enter image description here

Edit: ListPlot3D also

The problem concerns also ListPlot3D in the exact same way (see also this related post).

For example:

MapAt[#*30000 &, xyz, {All, 2}] // ListPlot3D 

enter image description here

$\endgroup$
4
$\begingroup$

I still don't understand the source of this behavior, it definitely seems to be some sort of bug. Compare

data = Import["http://pastebin.com/raw.php?i=2p4ew0NJ", "Table"];
ListDensityPlot[data, PlotLegends -> Automatic, 
 PlotRange -> {{0, 13000}, {0, 8}, {0, 0.0007}}]

enter image description here

with this workaround:

cmfunc = Interpolation[data];
DensityPlot[cmfunc[x, y], {x, 0, 13000}, {y, 0, 8.8}, 
 PlotRange -> {0, .0007}, PlotPoints -> 100, PlotLegends -> Automatic]

enter image description here

I am using version 10.2 (Linux)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.