# Using Function for Contours

Is this a bug in Contours or I am using the function incorrectly?

In the second code the function works well but in the third code it fails.

The first and third images should be the same.

ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -2, 2}, ContourShading -> None,
Contours -> Table[{k, Red}, {k, -4, 4, 1}]]

ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -2, 2}, ContourShading -> None,
Contours -> Function[{min, max}, Table[k, {k, min, max, 1}]]]

ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -2, 2}, ContourShading -> None,
Contours -> Function[{min, max}, Table[{k, Red}, {k, min, max, 1}]]]


• Maybe still not implemented. ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -2, 2}, ContourShading -> None, Contours -> Function[{min, max}, Table[k, {k, min, max, 1}]], ContourStyle -> {Red, Cyan, Red}] Commented Apr 19 at 8:22

\$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global*"]

{zmin, zmax} = #[{x^2 - y^2, -2 <= x <= 2, -2 <= y <= 2}, {x, y}] & /@
{MinValue, MaxValue}

(* {-4, 4} *)

zdelta = 1;

ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -2, 2},
Contours -> Table[
{k, {Thick, ColorData["Rainbow"][(k - zmin)/(zmax - zmin)]}},
{k, zmin, zmax, zdelta}],
PlotLegends -> BarLegend[{"Rainbow", {-4, 4}},
LegendMarkerSize -> 360],
MaxRecursion -> 4]


When using Function with Contours option also use ContourStyle option

ContourPlot[x^2 - y^2, {x, -2, 2}, {y, -2, 2},

• This does not answer the question. I know how to color contours by other means (like without function or with restricted function and with ContourStyle). The point is to do it with function in option Contours` only and to judge whether it is a bug or not. Commented Apr 19 at 12:56