NCL Home> Application examples> Plot techniques

Contour Labels

conLab_1.ncl: Demonstrates the default behavior of three modes of contour labeling.

cnLineLabelPlacementMode can be set to randomized (default), constant, or computed. Note that only the constant method makes the label part of the line so that the line is not drawn through it.
conLab_2.ncl: Uses several resources to mimic the behavior of "constant" masking in example 1.

The resource cnLabelMasking has been modified (version 4.2.0.a027 or later) that allows the user to mask the contour labels. See the script for the other resources that were used.
conLab_3.ncl: Uses various resources to modify the spacing and number of line labels.

cnLineLabelInterval determines what sequential contours are labeled. The default is every other contour line (value=2).
cnLineDashSegLenF normally controls the length of dash lines, but it also has an effect on contour labeling when cnLineLabelPlacementMode is set to constant. With this placement mode, the labels are actually part of the line, so cnLineDashSegLenF controls label spacing.
conLab_4.ncl: Demonstrates drawing labels with a background color.

cnLineLabelBackgroundColor allows you to choose a color. The default is transparent. This resource can not be used with a cnLineLabelPlacementMode = constant.
conLab_5.ncl: Demonstrates a new label density resource available since NCL version 4.2.0.a031 or later.

cnLineLabelDensityF can increase or decrease the number of labels along a contour line. The default value for this resource is 0.0, no change. Values greater than 0.0 increase the number of line labels while negative values decrease the number of line labels. The resource does not work if cnLineLabelPlacementMode is set to "constant".

Not that the effect is dependent upon the data to be plotted, the format of the labels, and various other variables. Therefore, there is no general relationship between the value chosen and the number of labels. It will be plot dependent.
conLab_6.ncl: Demonstrates how easy it is to alter the appearance and frequency of line labels.

Plot #1 (top) shows the default NCL line labeling. Plot #2 (middle) uses cnLineLabelDensityF to increase the number of line labels, and cnLineLabelInterval to label every line instead of the default every other line. Plot #3 (bottom) uses cnLabelMasking to wipe out the contour line behind each line label, thereby making the line labels easier to read.