help axis_options
-------------------------------------------------------------------------------
Title
[G] axis_options -- Options for specifying numeric axes
Syntax
axis_scale_options description
---------------------------------------------------------------------
{y|x|t}scale(axis_description) log scales, range, appearance
---------------------------------------------------------------------
See [G] axis_scale_options.
axis_label_options description
---------------------------------------------------------------------
{y|x|t}label(rule_or_values) major ticks plus labels
{y|x|t}tick(rule_or_values) major ticks only
{y|x|t}mlabel(rule_or_values) minor ticks plus labels
{y|x|t}mtick(rule_or_values) minor ticks only
---------------------------------------------------------------------
(also allows control of grid lines; see [G] axis_label_options)
axis_title_options description
---------------------------------------------------------------------
{y|x|t}title(axis_title) specify axis title
---------------------------------------------------------------------
See [G] axis_title_options.
Description
Axes are the graphical elements that indicate the scale.
Options
yscale(), xscale(), and tscale() specify how the y, x, and t axes are
scaled (arithmetic, log, reversed), the range of the axes, and the
look of the lines that are the axes. See [G] axis_scale_options.
tscale() is an extension of xscale().
ylabel(), ytick(), ymlabel(), ymtick(), xlabel(), ..., xmtick(), and
tlabel(), ..., tmtick() specify how the axes should be labeled and
ticked. These options allow you to control the placement of major
and minor ticks and labels. Also, these options allow you to add or
to suppress grid lines on your graphs. See [G] axis_label_options.
tlabel(), ..., tmtick() are extensions of xlabel(), ..., xmtick(),
respectively.
ytitle(), xtitle(), and ttitle() specify the titles to appear next to the
axes. See [G] axis_title_options. ttitle() is a synonym of
xtitle().
Remarks
Numeric axes are allowed with graph twoway and graph matrix and are
allowed for one of the axes of graph bar, graph dot, and graph box. How
the numeric axes look is affected by the axis_options.
Remarks are presented under the following headings:
Use of axis-appearance options with graph twoway
Multiple y and x scales
Axis on the left, axis on the right?
Use of axis-appearance options with graph twoway
When you type
. scatter yvar xvar
the resulting graph will have y and x axes. How the axes look will be
determined by the scheme; see [G] schemes intro. The axis_options allow
you to modify the look of the axes in terms of whether the y axis is on
the left or on the right, whether the x axis is on the bottom or on the
top, the number of major and minor ticks that appear on each axis, the
values that are labeled, and the titles that appear along each.
For instance, you might type
. scatter yvar xvar, ylabel(#6) ymtick(##10) ytitle("values of y")
xlabel(#6) xmtick(##10) xtitle("values of x")
to draw a graph of yvar versus xvar, putting on each axis approximately
six labels and major ticks and 10 minor ticks between major ticks, and
labeling the y axis "values of y" and the x axis "values of x".
. scatter yvar xvar, ylabel(0(5)30) ymtick(0(1)30) ytitle("values of
y") xlabel(0(10)100) xmtick(0(5)100) xtitle("values of x")
would draw the same graph, putting major ticks on the y axis at 0, 5, 10,
..., 30 and minor ticks at every integer over the same range, and putting
major ticks on the x axis at 0, 10, ..., 100 and minor ticks at every
five units over the same range.
The way we have illustrated it, it appears that the axis options are
options of scatter, but that is not so. Here they are options of twoway,
and the "right" way to write the last command is
. twoway (scatter yvar xvar), ylabel(0(5)30) ymtick(0(1)30)
ytitle("values of y") xlabel(0(10)100) xmtick(0(5)100)
xtitle("values of x")
The parentheses around (scatter yvar xvar) and the placing of the
axis-appearance options outside the parentheses make clear that the
options are aimed at twoway rather than at scatter. Whether you use the
||-separator notation or the ()-binding notation makes no difference, but
it is important to understand that there is only one set of axes,
especially when you type more complicated commands, such as
. twoway (scatter yvar xvar)
(scatter y2var x2var)
, ylabel(0(5)30) ymtick(0(1)30) ytitle("values of y")
xlabel(0(10)100) xmtick(0(5)100) xtitle("values of x")
There is one set of axes in the above, and it just so happens that both
yvar versus xvar and y2var versus x2var appear on it. You are free to
type the above command how you please, such as
. scatter yvar xvar ||
scatter y2var x2var ||,
ylabel(0(5)30) ymtick(0(1)30) ytitle("values of y")
xlabel(0(10)100) xmtick(0(5)100) xtitle("values of x")
or
. scatter yvar xvar ||
scatter y2var x2var, ylabel(0(5)30) ymtick(0(1)30)
ytitle("values of y") xlabel(0(10)100)
xmtick(0(5)100) xtitle("values of x")
or
. scatter yvar xvar, ylabel(0(5)30) ymtick(0(1)30)
ytitle("values of y") xlabel(0(10)100)
xmtick(0(5)100) xtitle("values of x") ||
scatter y2var x2var
The above all result in the same graph, even though the last makes it
appear that the axis options are associated with just the first scatter,
and the next to the last makes it appear that they are associated with
just the second. However you type it, the command is really twoway.
twoway draws twoway graphs with one set of axes (or one set per
by-group), and all the plots that appear on the twoway graph share that
set.
Multiple y and x scales
Actually, a twoway graph can have more than one set of axes. Consider
the command:
. twoway (scatter yvar xvar) (scatter y2var x2var, yaxis(2))
The above graphs yvar versus xvar and y2var versus x2var, but two y
scales are provided. The first (which will appear on the left) applies
to yvar, and the second (which will appear on the right) applies to
y2var. The yaxis(2) option says that the y axis of the specified scatter
is to appear on the second y scale.
See [G] axis_choice_options.
Axis on the left, axis on the right?
When there is only one y scale, whether the axis appears on the left or
the right is determined by the scheme; see [G] schemes intro. The
default scheme puts the y axis on the left, but the scheme that mirrors
the style used by The Economist puts it on the right:
scatter yvar xvar, scheme(economist)
Specifying scheme(economist) will change other things about the
appearance of the graph, too. If you just want to move the y axis to the
right, you can type
scatter yvar xvar, yscale(alt)
As explained in axis_scale_options, yscale(alt) switches the axis from
one side to the other, so if you typed
scatter yvar xvar, scheme(economist) yscale(alt)
you would get The Economist scheme but with the y axis on the left.
xscale(alt) switches the x axis from the bottom to the top or from the
top to the bottom; see [G] axis_scale_options.
Also see
Manual: [G] axis_options
Help: [G] axis_label_options, [G] axis_scale_options, [G]
axis_title_options; [G] axis_choice_options; [G] region_options