Stata 15 help for axis_scale_options

[G-3] axis_scale_options -- Options for specifying axis scale, range, and look

Syntax

axis_scale_options are a subset of axis_options; see [G-3] axis_options.

axis_scale_options Description ------------------------------------------------------------------------- yscale(axis_suboptions) how y axis looks xscale(axis_suboptions) how x axis looks tscale(axis_suboptions) how t (time) axis looks zscale(axis_suboptions) how contour legend axis looks ------------------------------------------------------------------------- The above options are merged-implicit; see repeated options.

axis_suboptions Description ------------------------------------------------------------------------- axis(#) which axis to modify; 1 < # < 9 [no]log use logarithmic scale [no]reverse reverse scale to run from max to min range(numlist) expand range of axis range(datelist) expand range of t axis (tscale() only)

off and on suppress/force display of axis fill allocate space for axis even if off alt move axis from left to right or from top to bottom

fextend extend axis line through plot region and plot region's margin extend extend axis line through plot region noextend do not extend axis line at all noline do not draw axis line line force drawing of axis line

titlegap(relativesize) margin between axis title and tick labels outergap(relativesize) margin outside axis title

lstyle(linestyle) overall style of axis line lcolor(colorstyle) color and opacity of axis line lwidth(linewidthstyle) thickness of axis line lpattern(linepatternstyle) axis pattern (solid, dashed, etc.) -------------------------------------------------------------------------

Description

The axis_scale_options determine how axes are scaled (arithmetic, log, reversed), the range of the axes, and the look of the lines that are the axes.

Options

yscale(axis_suboptions), xscale(axis_suboptions), and tscale(axis_suboptions) specify the look of the y, x, and t axes. The t axis is an extension of the x axis. Inside the parentheses, you specify axis_suboptions.

zscale(axis_suboptions); see Contour axes -- zscale() below.

Suboptions

axis(#) specifies to which scale this axis belongs and is specified when dealing with multiple y or x axes; see [G-3] axis_choice_options.

log and nolog specify whether the scale should be logarithmic or arithmetic. nolog is the usual default, so log is the option. See Obtaining log scales under Remarks below.

reverse and noreverse specify whether the scale should run from the maximum to the minimum or from the minimum to the maximum. noreverse is the usual default, so reverse is the option. See Obtaining reversed scales under Remarks below.

range(numlist) specifies that the axis be expanded to include the numbers specified. Missing values, if specified, are ignored. See Specifying the range of a scale under Remarks below.

range(datelist) (tscale() only) specifies that the axis be expanded to include the specified dates; see datelist. Missing values, if specified, are ignored. See [TS] tsline for examples.

off and on suppress or force the display of the axis. on is the default and off the option. See Suppressing the axes under Remarks below.

fill goes with off and is seldom specified. If you turned an axis off but still wanted the space to be allocated for the axis, you could specify fill.

alt specifies that, if the axis is by default on the left, it be on the right; if it is by default on the bottom, it is to be on the top. The following would draw a scatterplot with the y axis on the right:

. scatter yvar xvar, yscale(alt)

fextend, extend, noextend, line, and noline determine how much of the line representing the axis is to be drawn. They are alternatives.

noline specifies that the line not be drawn at all. The axis is there, ticks and labels will appear, but the line that is the axis itself will not be drawn.

line is the opposite of noline, for use if the axis line somehow got turned off.

noextend specifies that the axis line not extend beyond the range of the axis. Say that the axis extends from -1 to +20. With noextend, the axis line begins at -1 and ends at +20.

extend specifies that the line be longer than that and extend all the way across the plot region. For instance, -1 and +20 might be the extent of the axis, but the scale might extend from -5 to +25, with the range [-5,-1) and (20,25] being unlabeled on the axis. With extend, the axis line begins at -5 and ends at 25.

fextend specifies that the line be longer than that and extend across the plot region and across the plot region's margins. For a definition of the plot region's margins, see [G-3] region_options. If the plot region has no margins (which would be rare), fextend means the same as extend. If the plot region does have margins, extend would result in the y and x axes not meeting. With fextend, they touch.

fextend is the default with most schemes.

titlegap(relativesize) specifies the margin to be inserted between the axis title and the axis tick labels; see [G-4] relativesize.

outergap(relativesize) specifies the margin to be inserted outside the axis title; see [G-4] relativesize.

lstyle(linestyle), lcolor(colorstyle), lwidth(linewidthstyle), and lpattern(linepatternstyle) determine the overall look of the line that is the axis; see lines.

Remarks

axis_scale_options are a subset of axis_options; see [G-3] axis_options for an overview. The other appearance options are

axis_label_options (see [G-3] axis_label_options)

axis_title_options (see [G-3] axis_title_options)

Remarks are presented under the following headings:

Use of the yscale() and xscale() Specifying the range of a scale Obtaining log scales Obtaining reversed scales Suppressing the axes Contour axes -- zscale()

Use of the yscale() and xscale()

yscale() and xscale() specify the look of the y and x axes. Inside the parentheses, you specify axis_suboptions, for example:

. twoway (scatter ...) ..., yscale(range(0 10) titlegap(1))

yscale() and xscale() may be abbreviated ysc() and xsc(), suboption range() may be abbreviated r(), and titlegap() may be abbreviated titleg():

. twoway (scatter ...) ..., ysc(r(0 10) titleg(1))

Multiple yscale() and xscale() options may be specified on the same command, and their results will be combined. Thus the above command could also be specified

. twoway (scatter ...) ..., ysc(r(0 10)) ysc(titleg(1))

Suboptions may also be specified more than once, either within a yscale() or xscale() option, or across multiple options, and the rightmost suboption will take effect. In the following command, titlegap() will be 2 and range(), 0 and 10:

. twoway (scatter ...) ..., ysc(r(0 10)) ysc(titleg(1)) ysc(titleg(2))

Specifying the range of a scale

To specify the range of a scale, specify the {y|x}scale(range(numlist)) option. This option specifies that the axis be expanded to include the numbers specified.

Consider the graph

. scatter yvar xvar

Assume that it resulted in a graph where the y axis varied over 1--100 and assume that, given the nature of the y variable, it would be more natural if the range of the axis were expanded to go from 0 to 100. You could type

. scatter yvar xvar, ysc(r(0))

Similarly, if the range without the yscale(range()) option went from 1 to 99 and you wanted it to go from 0 to 100, you could type

. scatter yvar xvar, ysc(r(0 100))

If the range without yscale(range()) went from 0 to 99 and you wanted it to go from 0 to 100, you could type

. scatter yvar xvar, ysc(r(100))

Specifying missing for a value leaves the current minimum or maximum unchanged; specifying a nonmissing value changes the range, but only if the specified value is outside the value that would otherwise have been chosen. range() never narrows the scale of an axis or causes data to be omitted from the plot. If you wanted to graph yvar versus xvar for the subset of xvar values between 10 and 50, typing

. scatter yvar xvar, xsc(r(10 50))

would not suffice. You need to type

. scatter yvar xvar if xvar>=10 & xvar<=50

Obtaining log scales

To obtain log scales specify the {y|x}scale(log) option. Ordinarily when you draw a graph, you obtain arithmetic scales:

. sysuse lifeexp, clear

. scatter lexp gnppc (click to run)

To obtain the same graph with a log x scale, we type

. scatter lexp gnppc, xscale(log) (click to run)

We obtain the same graph as if we typed

. generate log_gnppc = log(gnppc)

. scatter lexp log_gnppc

The difference concerns the labeling of the axis. When we specify {y|x}scale(log), the axis is labeled in natural units. Here the overprinting of the 30,000 and 40,000 is unfortunate, but we could fix that by dividing gnppc by 1,000.

Obtaining reversed scales

To obtain reversed scales -- scales that run from high to low -- specify the {y|x}scale(reverse) option:

. sysuse auto, clear

. scatter mpg weight, yscale(rev) (click to run)

Suppressing the axes

There are two ways to suppress the axes. The first is to turn them off completely, which means that the axis line is suppressed, along with all of its ticking, labeling, and titling. The second is to simply suppress the axis line while leaving the ticking, labeling, and titling in place.

The first is done by {y|x}scale(off) and the second by {y|x}scale(noline). Also, you will probably need to specify the plotregion(style(none)) option; see [G-3] region_options.

The axes and the border around the plot region are right on top of each other. Specifying plotregion(style(none)) will do away with the border and reveal the axes to us:

. sysuse auto, clear

. scatter mpg weight, plotregion(style(none)) (click to run)

To eliminate the axes, type

. scatter mpg weight, plotregion(style(none)) yscale(off) xscale(off) (click to run)

To eliminate the lines that are the axes while leaving in place the labeling, ticking, and titling, type

. scatter mpg weight, plotregion(style(none)) yscale(noline) xscale(noline) (click to run)

Rather than using {y|x}scale(noline), you may specify {y|x}scale(lstyle(noline)) or {y|x}scale(lstyle(none)). They all mean the same thing.

Contour axes -- zscale()

The zscale() option is unusual in that it applies not to axes on the plot region, but to the axis that shows the scale of a contour legend. It has effect only when the graph includes a twoway contour plot; see [G-2] graph twoway contour. In all other respects, it acts like xscale(), yscale(), and tscale().


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index