Bug introduced in 8 or earlier and persisting through 11.0.1 or later
ListContourPlot uses the wrong colouring here:
res = Import["https://dl.dropboxusercontent.com/u/38623/res.wdx", "WDX"];
ListContourPlot[res, Contours -> Range[0.66, 0.9, 0.02], ColorFunction -> "Rainbow"]
The contour plot shows that the function value decreases around the bottom middle, even though it reaches its maximum there in reality.
The tooltips for the contour values between the red and orange regions are correct however: one contour shows 0.84 and the other 0.86. It's just the colouring that's wrong.
Compare
ListDensityPlot[res, ColorFunction -> "Rainbow"]

What is the simplest, most convenient workaround for this problem? Also, is this a bug or am I missing something? Can anyone explain why this happens?
I do need these specific contour values. Interpolation + ContourPlot gives the exact same result:
if = Interpolation[res]
ContourPlot[if[x, y], {x, 0.1, 1}, {y, 7, 9.4},
Contours -> Range[0.66, 9, 0.02], ColorFunction -> "Rainbow"]
Answer
This seems like a bug of some kind to me. But replacing the second argument to Range with the very last contour you want to see, as a workaround, gives the same contours but with proper coloring
Grid[{ListContourPlot[res, Contours -> Range[0.2, #, 0.02],
ColorFunction -> "Rainbow",
PlotLegends -> Automatic] & /@ {.86, .90}}]
And the bug seems to go away if you increase the scale of your data by a factor of 10, but it shows a completely different wrong color if you decrease it by a factor of 10.
Grid@Partition[#, 3] &@
Table[ListContourPlot[{#1, #2, x #3} & @@@ res,
Contours -> Range[x .2, x .9, x 0.02], ColorFunction -> "Rainbow",
ImageSize -> 300], {x, {.001, .01, .1, 1, 10, 100}}]
So apparently ListContourPlot and ContourPlot have trouble with their ColorFunctionScaling when the data is smaller than 1.



Comments
Post a Comment