Hmisc (version 4.0-0)

mgp.axis: Draw Axes With Side-Specific mgp Parameters

Description

mgp.axis is a version of axis that uses the appropriate side-specific mgp parameter (see par) to account for different space requirements for axis labels vertical vs. horizontal tick marks. mgp.axis also fixes a bug in axis(2,...) that causes it to assume las=1.

mgp.axis.labels is used so that different spacing between tick marks and axis tick mark labels may be specified for x- and y-axes. Use mgp.axis.labels('default') to set defaults. Users can set values manually using mgp.axis.labels(x,y) where x and y are 2nd value of par('mgp') to use. Use mgp.axis.labels(type=w) to retrieve values, where w='x', 'y', 'x and y', 'xy', to get 3 mgp values (first 3 types) or 2 mgp.axis.labels.

Usage

mgp.axis(side, at = NULL, ..., mgp = mgp.axis.labels(type = if (side == 1 | side == 3) "x" else "y"), axistitle = NULL, cex.axis=par('cex.axis'), cex.lab=par('cex.lab'))
mgp.axis.labels(value,type=c('xy','x','y','x and y'))

Arguments

side,at
see par
...
arguments passed through to axis
mgp,cex.axis,cex.lab
see par
axistitle
if specified will cause axistitle to be drawn on the appropriate axis as a title
value
vector of values to which to set system option mgp.axis.labels
type
see above

Value

mgp.axis.labels returns the value of mgp (only the second element of mgp if type="xy" or a list with elements x and y if type="x or y", each list element being a 3-vector) for the appropriate axis if value is not specified, otherwise it returns nothing but the system option mgp.axis.labels is set.mgp.axis returns nothing.

Side Effects

mgp.axis.labels stores the value in the system option mgp.axis.labels

See Also

par

Examples

Run this code
## Not run: 
# mgp.axis.labels(type='x')  # get default value for x-axis
# mgp.axis.labels(type='y')  # get value for y-axis
# mgp.axis.labels(type='xy') # get 2nd element of both mgps
# mgp.axis.labels(type='x and y')  # get a list with 2 elements
# mgp.axis.labels(c(3,.5,0), type='x')  # set
# options('mgp.axis.labels')            # retrieve
# 
# plot(..., axes=FALSE)
# mgp.axis(1, "X Label")
# mgp.axis(2, "Y Label")
# 
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace