NCL Home> Application examples> Plot techniques || Data files for examples

Contour Effects

There are numerous examples of contour effects throughout this tutorial, but we decided to create a separate page on the topic in order to highlight the functions some of our contributors are making.
coneff_1.ncl: Shade the zero line double thickness.

gsnContourZeroLineThicknessF sets the thickness of the zero contour.


coneff_2.ncl: Shades the zero line to a user defined thickness value.

gsnContourZeroLineThicknessF sets the thickness of the zero contour.


coneff_3.ncl: Draws negative contours as dashed, and draws the zero line as double thickness.

gsnContourZeroLineThicknessF doubles the thickness of the zero contour, gsnContourNegLineDashPattern dashes the negative contours, and gsnContourPosLineDashPattern dashes the positive contours.

coneff_4.ncl: Draws negative contours as dashed, and draws removes the zero line.

gsnContourZeroLineThicknessF eliminates the zero contour (by setting = 0), gsnContourNegLineDashPattern dashes the negative contours, and gsnContourPosLineDashPattern dashes the positive contours.

coneff_5.ncl: Draws negative contours as dashed.

gsnContourNegLineDashPattern dashes the negative contours.

coneff_6.ncl: Not only draws negative contours as dashed, but draws pos,neg, and zero contours in different colors.

ColorNegDashZeroPosContour is used to create this contour effect.

mpOutlineOn = True, turns on the continental map outline.

coneff_7.ncl: 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 or later.) We recommend you use this instead. See coneff_13 below for a demonstration of how to use gsn_contour_shade.

ShadeLtContour
ShadeGtContour
ShadeLtGtContour
ShadeGeLeContour

Note! ShadeLtContour, 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.

coneff_8.ncl: Will shade values using color rather than fill patterns.

ColorShadeLeGeContour is used to create this contour effect. Note: ColorShadeLeGeContour has been superceded by the more versatile gsn_contour_shade. We recommend you use this instead. See coneff_13 below for a demonstration of how to use gsn_contour_shade.

coneff_9.ncl: 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".

coneff_10.ncl: 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 use.

coneff_11.ncl: As of NCL version 4.2.0.a029, you can control the size of the dots in the fill patterns #17. This is useful for publication in which the default dot size is too small when a figure is reduced.

cnFillDotSizeF will control the size of the dots in the stippling pattern (#17) in a contour plot.

coneff_12.ncl: 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 missing values.

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 using cnMissingValPerimThicknessF.

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.

coneff_13.ncl: 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 input arguments. 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.

iso_2.ncl: Demonstrates a color plot with labels instead of a colorbar. From the iso-level example page.