Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program:
Example Contour Plot

Example Program

proc template;
 define statgraph contourplotparm;
   begingraph;
     entrytitle "Contour Plot of Height and Weight";
     layout overlay /
         xaxisopts=(offsetmin=0 offsetmax=0
           linearopts=(thresholdmin=0 thresholdmax=0))
         yaxisopts=(offsetmin=0 offsetmax=0
           linearopts=(viewmax=250
                       thresholdmin=0 thresholdmax=0));
       contourplotparm x=height y=weight z=density /
         contourtype=fill nhint=12
           name="Contour" colormodel=twocolorramp;
       continuouslegend "Contour" / title="Density";
     endlayout;
   endgraph;
 end;
run;
proc sgrender data=sashelp.gridded template=contourplotparm;
run;

Statement Summary

A CONTOURPLOTPARM statement uses the CONTOURTYPE= option to specify the type of contour plot to generate. Contour types that display fills or gradients but no contour lines can use only a CONTINUOUSLEGEND statement to represent the contour level values in a legend. Contour types that display lines can use either a CONTINUOUSLEGEND or DISCRETELEGEND statement to identify contour level values.
By default, the CONTOURPLOTPARM statement assumes that the X-Y grid is complete. If the grid is not complete, then set the GRIDDED= option to FALSE so that the plot calculates the values needed to complete into a grid with a bounding rectangle.
For filled or gradient contour types, small gaps might be visible between the axes and the bounding box of the contour data. To eliminate these gaps, set the axis options of the LAYOUT OVERLAY statement as follows:
XAXISOPTS=(OFFSETMIN=0  OFFSETMAX=0
           LINEAROPTS=(THRESHOLDMIN=0 THRESHOLDMAX=0))

YAXISOPTS=(OFFSETMIN=0  OFFSETMAX=0 
           LINEAROPTS=(THRESHOLDMIN=0 THRESHOLDMAX=0))
Contour plots do not support the tooltips that are enabled by the IMAGEMAP= option in the ODS GRAPHICS statement.

Required Arguments

X=numeric-column | expression
specifies the X coordinates for the grid.
Y=numeric-column | expression
specifies the Y coordinates for the grid.
Z=numeric-column | expression
specifies the contour response values.

Options

Statement Option
Description
Specifies a style element that is used to determine the colors of filled or gradient contours.
Specifies how the contour is displayed.
Specifies whether the grid formed by the X and Y values is complete.
Specifies the label for a legend.
Specifies the properties of the contour lines.
Specifies the color and font attributes of the contour line labels.
Specifies the alignment of the contour line labels.
Specifies the format of the contour line labels.
Specifies the position of the contour line labels.
Assigns a name to a plot statement for reference in other template statements.
Specifies the suggested number of contour levels for the Z variable.
Specifies the actual number of contour levels for the Z variable.
Specifies that the data columns for this plot and the plot type be used for determining default axis features.
Specifies whether to reverse the gradient defined by the COLORMODEL= option.
Specifies whether data are mapped to the primary X (bottom) axis or the secondary X2 (top) axis.
Specifies whether data are mapped to the primary Y (left) axis or the secondary Y2 (right) axis.
COLORMODEL=style-element
specifies a style element that is used to determine the colors of filled or gradient contours.
Default: The ThreeColorRamp style element.
style-element
Name of a style element. The style element can contain these style attributes:
STARTCOLOR Specifies a color for the smallest data value of the Z variable.
NEUTRALCOLOR Specifies a color for the midpoint of the range of the Z variable.
ENDCOLOR Specifies a color for the highest data value of the Z variable.
Interaction: The REVERSECOLORMODEL= option can be used to reverse the start and end colors of the ramp assigned to the color model.
Interaction: The NEUTRALCOLOR attribute is not used for two-color ramps.
CONTOURTYPE= LINE | LABELEDLINE | FILL | GRADIENT | LINEFILL | LINEGRADIENT | LABELEDLINEFILL | LABELEDLINEGRADIENT
specifies how the contour is displayed.
values for contourtype=
Default: The GraphContour:DisplayOpts style reference.
LINE
displays contour levels as unlabeled lines.
FILL
displays the area between the contour levels as filled. Each contour interval is filled with one color.
GRADIENT
displays a smooth gradient of color to represent contour levels.
LINEFILL
combines the LINE and FILL types. Each contour interval is filled with one color. Displays contour levels as unlabeled lines.
LINEGRADIENT
combines the LINE and GRADIENT types. Displays contour levels as unlabeled lines.
LABELEDLINE
adds labels to the LINE type, displaying contour levels as labeled lines.
LABELEDLINEFILL
adds labels to the LINEFILL type. Each contour interval is filled with one color. Displays contour levels as lines with labels showing contour level values.
LABELEDLINEGRADIENT
adds labels to the LINEGRADIENT type. Displays contour levels as lines with labels showing contour level values.
Interaction: The fill colors of the types that enable FILL or GRADIENT are controlled by the COLORMODEL= option.
Interaction: The line properties of the types that enable LINE or LABELEDLINE are controlled by the LINEATTRS= option.
Interaction: The label properties of the types that enable LABELEDLINE are controlled by the LINELABELATTRS= and LINELABELBASELINE= options.
Interaction: If a DISCRETELEGEND statement is associated with the contour, the legend is NOT displayed if CONTOURTYPE= is set to FILL or GRADIENT.
Interaction: If a CONTINUOUSLEGEND statement is associated with the contour, the legend is NOT displayed if CONTOURTYPE is set to LINE or LABELEDLINE.
GRIDDED=boolean
specifies whether the grid formed by the X and Y values is complete.
Default: TRUE
If set to FALSE, then additional calculations are performed.
For information about the algorithm used to calculate the grid, see “Mesoscale Objective Map Analysis Using Weighted Time-Series Observations.”(footnote1)
LEGENDLABEL= "string"
specifies a label for the legend item that is associated with this plot.
Default: The Z-variable label. If a label is not defined, the default is the Z-variable name.
Restriction: This option applies only to an associated DISCRETELEGEND statement.
LINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the contour lines. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphDataDefault style element.
Interaction: This option is honored only if the CONTOURTYPE= displays lines.
LINELABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the contour line labels. See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Default: The GraphValueText style element.
Interaction: This option is honored only if the CONTOURTYPE= displays labels.
LINELABELBASELINE=HORIZONTAL | TANGENT
specifies the text alignment of the contour line labels. Each contour line has a precomputed label point.
Default: HORIZONTAL
HORIZONTAL
specifies that each label is parallel to the X-axis. The label intersects its contour line and is centered at the label point.
TANGENT
specifies that each label is drawn tangent to the contour line at the label point. This reduces intersection with the contour line and causes labels to be tilted at various angles in relation to the X-axis.
Interaction: This option is honored only if the CONTOURTYPE= displays labels.
LINELABELFORMAT=format
specifies the format to use for the contour line labels.
Default: The format associated with the Z variable or BEST6. if no format is assigned.
Interaction: This option is honored only if the CONTOURTYPE= displays labels.
LINELABELPOSITION=MIDDLE | BEGIN | END
specifies the position for the contour line labels.
Default: MIDDLE
Interaction: This option is honored only if the CONTOURTYPE= option specifies labels.
NAME="string"
assigns a name to a plot statement for reference in other template statements.
Default: no default
Restriction: The string is case sensitive, cannot contain spaces, and must define a unique name within the template.
The specified name is used primarily in legend statements to indicate the colors associated with the Z values.
NHINT=integer
specifies the suggested number of contour levels for the Z variable.
Default: 7
The actual number of levels is adjusted to provide an appropriate number of levels for the data.
Interaction: This option is ignored if the NLEVELS= option is specified.
NLEVELS=integer
specifies the actual number of contour levels for the Z variable.
Default: The number of levels is determined internally, using the NHINT= value.
Interaction: This option overrides the NHINT= option.
Interaction: This option is ignored if CONTOURTYPE=GRADIENT.
PRIMARY=boolean
specifies that the data columns for this plot and the plot type be used for determining default axis features.
Default: FALSE
Restriction: This option is ignored if the plot is placed under a GRIDDED or LATTICE layout block.
Details: This option is needed only when two or more plots within an overlay-type layout contribute to a common axis. For more information, see When Plots Share Data and a Common Axis .
REVERSECOLORMODEL=boolean
specifies whether to reverse the gradient (color ramp) defined by the COLORMODEL= option.
Default: FALSE
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the secondary X2 (top) axis.
Default: X
Interaction: The overall plot specification and the layout type determine the axis display. For more information, see How Axis Features Are Determined.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the secondary Y2 (right) axis.
Default: Y
Interaction: The overall plot specification and the layout type determine the axis display. For more information, see How Axis Features Are Determined.
FOOTNOTE 1:
Barnes, Stanley L March 1973. “Mesoscale Objective Map Analysis Using Weighted Time-Series Observations.” Technical Memorandum (NOAA TM ERLNSSL-62), United States National Oceanic and Atmospheric Administration, Environmental Research Labs, Norman, OK..
[return]