Data files for some examples
Example pages containing:
This suite of examples shows how to change, create, draw, reverse, and
otherwise manipulate color maps (also known as "color tables").
Note: in NCL V6.1.0, a new
color model was introduced, which replaces the concept of associating
color maps with a workstation. For backwards compatibility, the old
color model is still supported. Many of the examples here are
for the workstation color map, but can still be very useful for
both color models.
NCL has a built-in list of
tables and a suite
of 650 named
colors you can use.
If you need to use CMYK color, then this is only supported with the
old style color model, and hence you must use "oldps" or "oldpdf" as
the output format. You can set this via a workstation resource, before
you call gsn_open_wks:
type = "oldps" ; cannot use "ps" or "pdf"
type@wkColorModel = "cmyk"
wks = gsn_open_wks(type,"example")
merging two colormaps on the workstation
. You can only do this
with two colormaps whose sum total is fewer than 256 colors.
The background/foreground colors are retained from the
first colormap only.
Note: merging color maps is not really necessary under the new color
on the RGBA examples page for a way to use multiple color maps on a
adding colors to an existing colormap, using
. This is only necessary for NCL
versions 6.0.0 or earlier, if you need to use one or
more named colors
and they are not in your current color map. In version 6.1.0
and later, named colors do not need to be added.
In order to add named colors to a colormap, you need to get their
corresponding RGB triplet from the $NCARG_ROOT/lib/ncarg/database/rgb.txt
file. This will be in values from 0 to 255, so you first need to
divide the values by 255 to get an RGB triplet.
to draw some illustrative
See the next example for how to create a colormap using this function.
: Uses values
from the above HSV color wheels to generate colormaps than span
from one color to another.
The colormap is drawn using gsn_labelbar_ndc.
to generate a color table that spans between given
You can optionally set the attributes "NumColorsInRange"
or "NumColorsInTable" to indicate the maximum number of
colors allowed in the table, or the number of colors in each
range between named colors.
: Uses the
to create a color map that reverses itself at the midpoint.
The colors passed to the function are
20 colors between each range.