PLOT Procedure

Example 13: Changing a Default Penalty

Features:

PLOT statement option:: PENALTIES=

Data set: CENSUS
This example demonstrates how changing a default penalty affects the placement of labels. The goal is to produce a plot that has labels that do not detract from how the points are scattered.

Program

options formchar="|----|+|---+=|-/\<>*";
   proc plot data=census;
      plot density*crimerate=state $ state /
           placement=(h=100 to 10 by alt * s=left right)
           penalties(4)=500  list=0
           haxis=0 to 13000 by 1000
           vaxis=by 100
           vspace=5;
   title 'A Plot of Population Density and Crime Rates';
run;

Program Description

Set the FORMCHAR option.Setting FORMCHAR to this exact string renders better HTML output when it is viewed outside of the SAS environment where SAS Monospace fonts are not available.
options formchar="|----|+|---+=|-/\<>*";
   proc plot data=census;
      plot density*crimerate=state $ state /
Specify the placement. PLACEMENT= specifies that the preferred placement states are 100 columns to the left and the right of the point, on the same line with the point.
           placement=(h=100 to 10 by alt * s=left right)
Change the default penalty. PENALTIES(4)= changes the default penalty for a free horizontal shift to 500, which removes all penalties for a horizontal shift. LIST= shows how far PROC PLOT shifted the labels away from their respective points.
           penalties(4)=500  list=0
Customize the axes. HAXIS= creates a horizontal axis long enough to leave space for the labels on the sides of the plot. VAXIS= specifies that the values on the vertical axis be in increments of 100.
           haxis=0 to 13000 by 1000
           vaxis=by 100
           vspace=5;
Specify the title.
   title 'A Plot of Population Density and Crime Rates';
run;

Output

Plot with Default Penalties Adjusted
A Plot of Population Density and Crime Rates
List of Point Locations, Penalties, and Placement States
List of Point Locations, Penalties, and Placement States