Data files for some examples
Example pages containing:
There are numerous examples of contour effects throughout the
. This page is dedicated
to specialized ways of controlling the look of contours, via shading,
transparency (new in V6.1.0), color fill, line thicknesses, and dashed
Three new resources were added in V6.1.0, allowing you to specify a
color palette for filled contours (and whether to span that color
palette), and controlling the opacity of color colors.
In addition, in V6.1.0,
the cnFillColors resource can now
be given an n x 4 array of RGBA values, allowing to specify the
opacity of individual colors.
Three other popular resources and a function include:
This page mentions some older methods for doing shading
and color fill, all of which have been superceded by
: A panel plot
demonstrating four ways to selectively shade contour data. All of
these functions require user defined fill patterns
The four functions listed below have been superceded by the single
function gsn_contour_shade. (Available in version 4.3.0 and later.)
We recommend you use this instead. See coneff_13 below for a demonstration of how to use
ShadeGtContour and ShadeLtGtContour all use greater (less)
than, and NOT greater (less) than or equal to. These functions will
find the closest CONTOUR less than the specified threshold value when
choosing when to start shading. This is important to note when the
threshold values are being set in the above functions. For example, if
there are contour levels at (/1.0,1.5,2.0,2.5/), and one wants to
shade all areas greater than 2., ShadeGtContour should be used as such: plot
= ShadeGtContour(plot,2.2,1) ShadeGtContour will select the first
contour less than the given threshold value, in this case it
will select the 2 contour level. Thus, all areas greater than 2. will
be shaded. If instead 2.0 is specified as the threshold value, then
all contours greater than 1.5 and higher will be shaded. This
is because the 1.5 contour is the next contour level less than (and
not equal to) the given threshold value of 2.
: Shows how to take the
function in example 6
to make a
particular line disappear.
The color "transparent" exists in NCL, so that in this example the line
is draw but colored "invisible".
: This example
illustrates the use of shadings and hatchings to create a black and
white plot. Actually, only one shading and one hatching pattern are
used but the density of the patterns are altered giving the impression
of several different patterns.
cnFillPatterns is the resource
that will allow the user specify what fill patterns to
: This example shows
how to apply a fill pattern and/or fill color to areas with missing
data. It also shows how to turn on the missing value perimeter
line. Note: NCL treats all values set to the attribute _FillValue as
When cnFillOn=True, NCL color
fills areas with missing values the backgroud color, in this case
white. This is shown in the top plot.
The middle plot has the missing value perimeter turned on via cnMissingValPerimOn, and the perimeter
line color is set to red using cnMissingValPerimColor. The missing value
fill pattern is set to solid fill (0) using cnMissingValFillPattern, and the missing
value fill color is set to blue using cnMissingValFillColor. Important note:
Even if you just want to fill missing areas with a color as in this
case, you still need to set cnMissingValFillPattern = 0. If you do
not set cnMissingValFillPattern,
the default = -1, and no pattern or color fill will be drawn.
The bottom plot is the result of setting cnMissingValFillPattern
= 5, cnMissingValFillScaleF
= .8 (increase the density of the fill pattern), changing cnMissingValPerimColor
to black, setting the missing value perimiter line to dash using cnMissingValPerimDashPattern,
and increasing the thickness of the missing value perimeter line by
For this example, cnFillMode is
set to the default "AreaFill". Not all of the above missing value
resources work with every cnFillMode. For instance, "CellFill" and
"RasterFill" modes do not allow use of cnMissingValFillPattern (= 0 for these
modes). Please consult the cnFillMode documentation for more details
about what missing value resources can be used with each FillMode.
: In version 4.3.0
a new function gsn_contour_shade
was added that allows you
to add shading and/or color fill between specified contour levels in
your plot. Note that the shading will always begin at a contour,
and not neccesarily at the user specified gsn_contour_shade
Check your plot to make sure that the results are what you expected.
The first frame shows how to do pattern shading four different ways, and the second
frame shows the same thing using solid color fill.
shaded contours on color-filled contours, and create two
separate labels for each set of contours.
: Using the cnLevelFlags
resource to control which
contour lines get drawn. You can set this resource to an array of
strings with the values "NoLine", "LineOnly", "LabelOnly", or
: Using the cnFillOpacityF
make the contour fill more transparent. The first frame has
no transparency, and the second frame has some transparency.
You may notice that the filled contours are slightly different over
land. This is because the land is filled in gray.