SAS Institute. The Power to Know

SAS/GRAPH(R) 9.2: Graph Template Language Reference

Previous | Next
LAYOUT LATTICE Statement

Example Program and Statement Details

The following graph was generated by the "Example Program":


layoutlatticeintro image

Example Program

This example shows a two-cell lattice (two columns, one row) layout where the Y axis is external (ROWAXES block) to both cells and the secondary Y axis is displayed on the right.
  • The ROWDATARANGE = UNION option assures that the data ranges of all Y= variables in the row cells are considered to construct a common axis range. This facilitates the visual comparison of the cells.
  • A SIDEBAR block is used to place the legend at the top of the lattice.
  
 proc template; 
  define statgraph layoutlattice; 
   begingraph; 
   entrytitle "Vehicle Gas Mileage"; 
   entryfootnote "Averages of 428 models from 38 manufactures"; 
     layout lattice / columns=2 rowdatarange=union; 
      layout overlay / cycleattrs=true; 
        barchart x=origin y=mpg_highway / 
         stat=mean barwidth=.8 name="H" ; 
        barchart x=origin y=mpg_city / 
         stat=mean barwidth=.5 name="C" ; 
      endlayout; 
      layout overlay / cycleattrs=true; 
        barchart x=type y=mpg_highway / 
         stat=mean barwidth=.8; 
        barchart x=type y=mpg_city / 
         stat=mean barwidth=.5; 
      endlayout; 
      sidebar / align=top; 
        discretelegend "H" "C" / border=false; 
      endsidebar; 
      rowaxes; 
        rowaxis / display=(tickvalues) 
         displaysecondary=(tickvalues) griddisplay=on; 
      endrowaxes; 
     endlayout; 
   endgraph; 
  end; 
 run; 
 proc sgrender data=sashelp.cars template=layoutlattice; 
 run;
 

Statement Summary

The LAYOUT LATTICE statement creates a grid of graphs that are aligned across columns and rows. For plot statements that are specified in the layout block or nested in a LAYOUT OVERLAY statement, the LATTICE layout automatically aligns the plot areas and tick display areas in the plots. Optionally, the layout can unify the scale of the data ranges that are displayed in the plots, based on the values set for the COLUMNDATARANGE= and ROWDATARANGE= options. The data ranges can be scaled separately for each column and or row, or they can be scaled across all columns and/or rows.

When the data-range scales are unified, you can simplify the layout by displaying only the external axes that apply to all of the graphs across the corresponding columns or rows. See "Axis Statements" for more details.

The following figure shows the parts of the Lattice layout with the default axis display (internal axes are displayed).


latticeinternaxes image


This next figure shows the parts of the Lattice layout when the graph display is simplified so that only external axes are displayed.


latticeexternaxes image


The columns and rows can be separated by areas called gutters , which are controlled by the COLUMNGUTTER= and ROWGUTTER= options. In addition, the COLUMNWEIGHTS= and ROWWEIGHTS= options can be used to allocate a proportion of available space to each row and column.

The LATTICE layout automatically decides how much area to allocate to cell contents:

  • text items have a fixed size based on the amount of text and the font properties
  • graphs take up the remaining space.

The layout's grid size is determined by the COLUMNS= and ROWS= options.

By default, the results of the statgraph-statements are placed into the grid sequentially from left to right, wrapping to a new row each time the current row is filled. You can use the ORDER= option to fill cells from top to bottom down a column, in which case the layout cells wrap to a new column each time the current column is filled.


Cell Contents

Axis Statements

Header Statements

Sidebar Statements

Options

Previous | Next | Top of Page