PROC GPLOT - PowerPoint PPT Presentation

About This Presentation
Title:

PROC GPLOT

Description:

legend1 down=2 position=(top left inside) frame cborder=blue cframe=gray cshadow=red; ... This is the default when position= (inside) ... – PowerPoint PPT presentation

Number of Views:331
Avg rating:3.0/5.0
Slides: 29
Provided by: jbl98
Learn more at: http://people.uncw.edu
Category:

less

Transcript and Presenter's Notes

Title: PROC GPLOT


1
PROC GPLOT
  • GPLOT is used to make two dimensional
    scatter-plots.
  • General Syntax
  • proc gplot datadata-set options
  • plot y-variablex-variable/options
  • run
  • quit

2
Multiple Plot Calls in a Plot Statement
  • Multiple y-variablex-variable calls are
    permitted in a plot statement, each generating a
    separate plot by default.
  • In the PROC GPLOT statement the uniform option
    gives each plot the same axis scales.
  • Assuming a common x-variable, the overlay option
    (in the plot statement) will cause the plots to
    be displayed on the same graph.
  • A legend is created for overlay plots if the
    legendlegendn option is included.

3
Multiple Plot Calls in a Plot Statement
  • proc gplot datasave.padgett
  • plot totmassplantht
  • /now do more than one plot at a time/
  • proc gplot datasave.padgett
  • plot totmassplantht bllenavgplantht
  • /we get two different plot/

4
PLOT and PLOT2
  • The PLOT2 statement allows for a second vertical
    axis to be displayed. Conditions
  • The x-variables in PLOT and PLOT2 must be the
    same.
  • Differing vaxis specifications can be made for
    each.

5
PLOT and PLOT2
  • /to get two different y-axes, try this/
  • proc gplot datasave.padgett
  • plot lleavesplantht /left/
  • plot2 bllenavgplantht/right/
  • /we get two plots on the same horizontal axis,
    but two different y-axes/

6
Plots According to Third Variable
  • Plots of the form y-variablex-variablez-variable
    produces a plot for each level of the
    z-variable.
  • Overlaying of plots is automatic.
  • A legend is produced automatically.
  • This legend can be modified in a similar manner
    to that of legends in bar charts.

7
Plots According to Third Variable
  • proc gplot datasave.padgett
  • plot totmassplanthtmarsh/legendlegend1
  • /distinguishes the plotting points by marsh and
    produces a legend so we can tell which is
    which/
  • / modify the legend as below /
  • legend1 down2 position(top left inside)
  • frame cborderblue cframegray cshadowred

8
LEGEND Statement Options
  • acrossn Legend is created with n entries per
    row.
  • downn Legend is created with n entries per
    column
  • Only one of ACROSS or DOWN should be specified.

9
LEGEND Statement Options
  • position(P1 P2 P3) Legend is positioned based
    on parameters specified.
  • Bottom, middle or top Sets vertical position.
  • Left, center or right Sets horizontal position.
  • Inside or outside Places legend inside or
    outside the graph area.
  • Default is (bottom center outside).

10
LEGEND Statement Options
  • modereserveprotectshare Controls how space
    is allocated to the plot and the legend.
  • Reserve Legend is allocated its own space in
    the output area. This is the default however,
    it cannot be used for position (inside).
  • Protect The legend is protected from the
    plotit is drawn over the plot. This is the
    default when position (inside).
  • Share Graphics are drawn over the legend if
    there is any intersection.

11
LEGEND Statement Options
  • frameDraws a frame around the legend in the
    first default color.
  • cborder Draws a frame around the legend in the
    specified color.
  • cframe Specifies the background color of the
    legend (or fills the frame).
  • cshadow Places a shadow behind the legend in
    the specified color.

12
LEGEND Statement Options
  • shape Controls appearance of the legend
    symbols. Specifications include
  • bar(width, height)
  • line(length)
  • symbol(width, height)
  • label(text-attributes text ) Defines the
    legend label text.
  • value(text-attributes-n text-n ) Defines the
    text associated with each legend symbol.

13
LEGEND Statement Options
  • Text attribute options include
  • c Text color.
  • f Text font.
  • h Text height.
  • t (value option only) Legend entry to be
    modified. Must precede the attributes being
    changed for that entry.
  • position (label option only) Positions legend
    label. Same options as legend position except
    for inside/outside (legend label is always
    inside).

14
Axis Modification
  • As an option in the plot statement (after the / )
    the user can specify haxisaxisn and/or
    vaxisaxisn to associate each axis with an axis
    statement.
  • A plot2 statement may include a vaxisaxisn
    specification as well.

15
Axis Modification
  • proc gplot datasave.projects
  • plot equipmntjobtotal/legendlegend1
  • haxisaxis1 vaxisaxis2
  • where stname in (NC SC VA)
  • legend1 down2 position(top left inside)
  • frame cborderblue cframegray cshadowred
  • axis1 label(Equipment Cost cblue
  • h2 fswissb) minornone
  • axis2 label(Total Costs)

16
The AXIS Statement
  • Axis statement options include
  • c (color) Specifies the color of the axis
    lines, tick marks and text.
  • width Specifies the thickness of the axis
    line.
  • order(value list or start to stop by increment)
    Specifies the data values corresponding to the
    major tick marks.
  • offset(n1,n2) Specifies the space from the
    start of the axis to the first tick and the end
    of the axis from the last tick, respectively.

17
The AXIS Statement
  • Axis statement options include
  • label(text-options text) or NONE Defines
    the axis label and its attributes.
  • value(text-options-n text-n) or NONE
    Defines major tick labels and attributes. Can
    be done as a group or one at a time.

18
The AXIS Statement
  • Attributes that can be specified within the
    label and value options
  • c Text color.
  • f Text font.
  • h Text height.
  • a Angle of the text string.
  • r Rotation of individual characters.
  • t (value option only) Tick mark to be
    modified. Must precede the attributes being
    changed for that tick.

19
Enhancing the Plot Area
  • The SYMBOL statement
  • Modifies the plotting symbol and related items
  • symboln options
  • n can range from 1 to 255.
  • If n is omitted it is taken as 1 by default.
  • SYMBOL statements are globalremain in effect
    until altered.
  • They are applied across the current color list if
    no color is specified.

20
Some SYMBOL Statement Options
  • v (value) Specifies the plotting symbol.
  • f (font) Specifies the font from which the
    plotting symbol is selected.
  • cv Symbol color.
  • h (height) Specifies the height of the
    symbol in cells.
  • pointlabel places y-value near each point

21
Inheritance in SYMBOL Statements
  • SYMBOL statements are global, some behaviors
  • Unmodified options will be inherited in
    subsequent definitions of a symbol statement.
  • Modifications to a symbol statement (e.g.
    symbol2) does not alter symbol statements with
    other numbers.
  • The statement goptions resetsymbol cancels all
    currently defined symbol statements.

22
Symbols
  • Default symbol specifications and results

23
Symbols
  • Write 3 symbol statements to change the colors,
    shapes,sizes of the 3 plotting symbols for NC,
    SC and VA
  • Go back to Padgett data and experiment with
    symbol statements

24
The GFONT Procedure
  • You can view a SAS/GRAPH font using PROC GFONT.
    The typical syntax will be
  • proc gfont namefont nobuild showroman
    ctextcolor
  • run
  • This code will display the font symbols with
    their standard counterparts. Fonts can be found
    in the fonts catalog in the SAShelp library.

25
Plot Lines
  • i (interpol) Specifies the interpolation
    method. Some of these include
  • join Joins the points with line segments
    (connect the dots).
  • sm Draws a smooth curve through the points,
    is a number that determines the level of
    smoothness (highersmoother).
  • needle Draws vertical lines from the data to 0
    (or the minimum value if all are greater than 0).

26
Plot Lines
  • Rlttypegtlt0gtltCLM or CLIltgtgt where
  • type is L, Q or C corresponding to linear,
    quadratic or cubic regression, respectively.
  • 0 forces the regression through the origin.
  • CLM and CLI specifies display of confidence
    limits for average (mean) predicted values and
    individual predictions.
  • specifies the confidence level between 50 and
    99.

27
Plot Lines
  • The SYMBOL statement can be used to control plot
    lines
  • l (line) Specifies a line type (various types
    of dashed lines). Valid values go from 1 to
    46.
  • w (width) Specifies the line thickness.
  • ci Sets the line color.
  • c (color) Sets colors for both lines and
    symbols.

28
Plot Lines
  • Now try your hand at some of the interpolation
    methods - see if you can find the best smoothing
    for total mass against plantht by marsh in the
    Padgett data
Write a Comment
User Comments (0)
About PowerShow.com