# Contour plot with positive and negative values

I want to make a simple contour plot with a function that takes positive and negative values (see below). I need the absolute values of the function to take the same shade in the contour plot (and greyscale would be best). Ultimately, I want the figure to look like a curved hill, where the top of the hill is the 0 contour.

Also, it would be great if I could remove the defined contour lines and smooth out the borders of the contours.

Thanks if you can help!

ContourPlot[(1 - c N z)/(N z - c N z^2) /. {c -> .01}, {N, 2, 50}, {z,


0, 20}]

You should avoid using N as a variable name as N is a reserved word for a function that gives the numerical value of an expression to a desired precision.

The smoothness can be improved by increasing the default number of points used to create the contours (PlotPoints). The color scheme can be changed by the ColorFunction option. To make the level '0' the maximum you'd want to use -Abs[...]:

ContourPlot[-Abs[(1 - c n z)/(n z - c n z^2) /. {c -> .01}], {n, 2, 50}, {z, 0, 20},
PlotPoints -> 100, ColorFunction -> GrayLevel]


To show a "hill" it might be better to use Plot3D:

Show[Plot3D[-Abs[(1 - c n z)/(n z - c n z^2) /. {c -> .01}], {n, 2,
50}, {z, 0, 20},
PlotPoints -> 100, ColorFunction -> GrayLevel],
Graphics3D[{Red,
Line[Table[{n, 1/(c n) /. c -> 0.01, 0}, {n, 5, 50}]]}]]


• I think the 3D plot will work best. Could you please tell me how to add a line to the "hilltop", where the function is zero? This is 1/(c n). – jmbierna Jun 21 '19 at 10:25
• @jmbierna Hilltop line added. – JimB Jun 21 '19 at 17:39

You can also use DensityPlot with ColorData[{"GrayTones", "Reversed"}] as the color function:

c =  .01;
DensityPlot[Abs[(1 - c n z)/(n z - c n z^2) ],
{n, 2, 50}, {z, 0, 20},
PlotPoints -> 100,
ColorFunction -> ColorData[{"GrayTones", "Reversed"}]]


Using ColorFunction -> (GrayLevel[1 - #] &) gives a similar picture.