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

View source: R/Misc.s

mgp.axisR Documentation

Draw Axes With Side-Specific mgp Parameters


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.


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'))


side, at

see par


arguments passed through to axis

mgp, cex.axis, cex.lab

see par


if specified will cause axistitle to be drawn on the appropriate axis as a title


vector of values to which to set system option mgp.axis.labels


see above


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


Frank Harrell

See Also



## 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)

harrelfe/Hmisc documentation built on May 19, 2024, 4:13 a.m.