To avoid tick-value collisions, a DISCRETE axis uses
several of the fit policies that a LINEAR axis uses. These policies
include THIN, ROTATE, STAGGER, ROTATETHIN, STAGGERTHIN, and STAGGERROTATE.
For information about these policies, see Avoiding Tick Value Collisions. A DISCRETE axis uses the following additional fit policies:
TRUNCATE |
TRUNCATETHIN |
STAGGERTRUNCATE |
EXTRACT |
TRUNCATEROTATE |
EXTRACTALWAYS |
TRUNCATESTAGGER |
You can set TICKVALUEFITPOLICY=TRUNCATE
to shorten the tick values. Axis values that are greater than 12 characters
in length are truncated to 12 characters. Ellipses are added to the
end of the truncated values to indicate that truncation has occurred.
When there is sufficient room on the axis to fit the full axis values,
no truncation occurs. For example, consider the following axis values.
Davidson, Richard |
Robertson, MaryAnn |
Johnston, Miranda |
Stenovich, Timothy |
McMillian, Joseph |
If the TRUNCATE policy
is used to fit these values on the X axis, the values are truncated
as shown in the following figure.
The compound policies
STAGGERTRUNCATE, TRUNCATEROTATE, TRUNCATESTAGGER, and TRUNCATETHIN
apply the first fit policy, and then apply the second fit policy when
fitting the tick values.
For a large number of
tick values, you can set TICKVALUEFITPOLICY=EXTRACT or TICKVALUEFITPOLICY=EXTRACTALWAYS
to move the axis values to an AXISLEGEND. In that case, on the axis,
the values are replaced with consecutive integers, and an AXISLEGEND
is added that cross references the integer values on the axis to the
actual axis values.
Note: If the axis type is not DISCRETE,
the TICKVALUEFITPOLICY=EXTRACT and TICKVALUEFITPOLICY=EXTRACTALWAYS
options are ignored.
When you set TICKVALUEFITPOLICY
to EXTRACT or EXTRACTALWAYS, you must also include the NAME= option
in your axis option list and an AXISLEGEND “
name” statement in your layout block.
In the AXISLEGEND statement, you must set
name to the value that you specified with the NAME= option in the axis
options list. Here is an example.
proc template;
define statgraph discretefitpolicyextract;
begingraph / border=false designwidth=450px designheight=400px;
entrytitle "Average MPG City by Make: Trucks";
Layout overlay /
yaxisopts=(label="Average MPG")
xaxisopts=(label="Make"
name="axisvalues"
tickvalueattrs=(size=9pt)
discreteopts=(tickvaluefitpolicy=extract));
barchart x=make y=mpg_city/orient=vertical stat=mean;
axislegend "axisvalues" / pad=(top=5 bottom=5) title="Makes";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=discretefitpolicyextract;
where type="Truck";
run;
The following figure
shows the resulting graph.
In this example, the
name AXISVALUES is used to associate the AXISLEGEND statement with
the X axis. The graph size is set to 450 pixels wide by 400 pixels
high. Since there is not enough room on the X axis to fit the make
names, the names are extracted to an axis legend as shown.
In most cases, the EXTRACT
policy moves the axis values to an axis legend only if a collision
occurs. If no collision occurs, the values are displayed on the axis
in the normal manner. In this example, if you increase the width of
the graph to 650 pixels and rerun the program, the legend disappears.
In contrast, the EXTRACTALWAYS policy moves the axis values to a legend
regardless of whether a collision occurs.
Note: With the exception of TICKVALUEFITPOLICY=EXTRACTALWAYS,
the TICKVALUEFITPOLICY= is never applied unless a tick value collision
situation is present. That is, you cannot force tick values to be
rotated, staggered, or moved to an axis legend if there is no collision
situation.