The default axis label is determined by the primary plot.
If a label is associated with the data column, the label is used.
If no column label is assigned, the column name is used for the axis
label. Each set of axis options provides LABEL= and SHORTLABEL= options
that can be used to change the axis label. By default, the font characteristics
of the label are set by the current style, but the plot statement's
LABELATTRS= option can be used to change the font characteristics.
See Axis Appearance Features Controlled by the Current Style. The following
examples show how axis labels are determined and how to set an axis
label.
Consider the following
data set, which contains information about bacteria and virus growth:
data growth;
do Hours=1 to 15 by .5;
Bacteria= 1000*10**( sqrt(Hours ));
Virus= 1000*10**(log(hours));
label bacteria="Bacteria Growth" virus="Virus Growth";
output;
end;
run;
To plot the growth trend
for both Bacteria and Virus in the same graph, we can use a simple
overlay of series plots. Whenever two or more columns are mapped to
the same axis, the primary plot determines the axis label. In the
following example, the first SERIESPLOT is primary by default, so
its columns determine the axis labels. In this case, the Y-axis label
is determined by the BACTERIA column.
layout overlay / cycleattrs=true;
seriesplot x=Hours y=Bacteria/ curvelabel="Bacteria";
seriesplot x=Hours y=Virus / curvelabel="Virus";
endlayout;
If we designate another plot
statement as "primary," its X= and Y= columns are used to label the
axes. The PRIMARY= option is useful when you desire a certain stacking
order of the overlays, but you want the axis characteristics to be
determined by a plot statement that is not the default primary plot
statement. In the following example, the second SERIESPLOT is set
as the primary plot, so its columns determine the axis labels. In
this case, the Y-axis label is determined by the VIRUS column.
layout overlay / cycleattrs=true;
seriesplot x=Hours y=Bacteria/ curvelabel="Bacteria";
seriesplot x=Hours y=Virus / curvelabel="Virus" primary=true ;
endlayout;
In the previous two examples, allowing
the primary plot to determine the Y-axis label did not result in an
appropriate label because a more generic label is needed. To achieve
this, you must set the axis label yourself with the LABEL= option.
layout overlay / cycleattrs=true
yaxisopts=(label="Growth of Virus and Bateria Cultures") ;
seriesplot x=Hours y=Bacteria/ curvelabel="Bacteria";
seriesplot x=Hours y=Virus / curvelabel="Virus";
endlayout;
Short Labels. If the data column's label is long, or if you supply a long string
for the label, the label might be truncated if it does not fit in
the allotted space. This might happen when you create a small graph
or when the font size for the axis label is large.
As a remedy for these situations, you can specify a "backup"
label with the SHORTLABEL= option. The short label is displayed whenever
the default label or the LABEL= string does not fit.
layout overlay / cycleattrs=true
yaxisopts=(label="Growth of Virus and Bacteria Cultures"
shortlabel="Growth" );
seriesplot x=Hours y=Bacteria/ curvelabel="Bacteria";
seriesplot x=Hours y=Virus / curvelabel="Virus";
endlayout;
Computed Columns. Another situation where you might want to control the axis label
is when a computed column is used.
layout overlay;
histogram eval(weight*height);
endlayout;
You can use an EVAL
expression to compute a new column that can be used as a required
argument. Such columns have manufactured names in the associated data
object. The name is based on the input column(s) and the functional
transformation that was applied to the input column. In this example,
BIN(WEIGHT*HEIGHT) is the manufactured name.