Bug introduced in 8 or earlier and persisting through 12.3.1 or later
Consider this example:
dat = Table[Re[Sqrt[1 - x^2 - y^2]], {x, -1.1, 1.1, 0.01}, {y, -1.1, 1.1, 0.01}];
Now pay special attention to the labelling of contours.
Here everything looks good:
ListContourPlot[dat, Contours -> {1., 0.9, 0.8, 0.7, 0.6, 0.5}, ContourLabels -> All]
But look!
ListContourPlot[dat, Contours -> Range[1, 0.5, -0.1], ContourLabels -> All]
The labelling of contours is now wrong: it is inverted. The largest one gets the smallest label.
As far as I can tell, the two ListContourPlot
commands are completely equivalent. One has a Range
, the second one has what the Range
would evaluate to.
Range[1, 0.5, -0.1]
(* {1., 0.9, 0.8, 0.7, 0.6, 0.5} *)
ListContourPlot
is not HoldAll
.
Attributes[ListContourPlot]
(* {Protected, ReadProtected} *)
I must be missing something obvious, but it's late here and I'm tired and I cannot see what. I'm using M10.4 on OS X.
Update: I solved the mystery: the difference between Range[1, 0.5, -0.1]
and {1., 0.9, 0.8, 0.7, 0.6, 0.5}
is that the former is a packed array. It seems this is just a plain old bug...
Range
-- would beListContourPlot[dat, Contours -> (# & /@ Range[1, 0.5, -0.1]), ContourLabels -> All]
$\endgroup$List@@Range[1, 0.5, -0.1]
fixes it too. $\endgroup$