Setting contour levels for use with symmetric color tables
This page shows how to set contour levels to go with a symmetric,
two-color color table. This kind of technique can be useful when you
need to represent your negative values using one color range (say,
blue for cooling), and your positive values to another color range
(say, red for warming).
Some sample symmetric color tables include:
If you have a symmetric color table (an equal number of colors in each
color map), and you provide a set of contour levels that go from -X to X,
then you will automatically get a nice symmetric set of colors above
and below 0.0, because NCL will automatically span your color map.
This example is identical to the one above, except that
is set to "PostDraw" so that you see the gray filled
land on top of the filled contours.
This script, which was contributed by Chad Herman, calculates the
proper values of gsnSpreadColorStart
for a two-color
color table to ensure such that negative values will be in the first
range of colors, and positive values will be in the second range of
You can tweak the plotting limits to see how well the code correctly
calculates the gsnSpreadColorStart/End values. Note that if the color bar
spacing is larger than the value where you want blue to transition to
red, the transition will not occur at the intended value because it's
too small to resolve.
Note: using gsnSpreadXXX resources is the older method of spanning a
color map, which still works. You can also
use cnFillPalette to directly
associated colors with a contour plot.