adjustAxisLabelMargins | R Documentation |
Adjust axis label margins to accommodate axis labels
adjustAxisLabelMargins(
x,
margin = 1,
maxFig = 1/2,
cex = par("cex"),
cex.axis = par("cex.axis"),
prefix = "-- -- ",
...
)
x |
vector of axis labels |
margin |
single integer value indicating which margin to adjust,
using the order by |
maxFig |
fraction less than 1, indicating the maximum size of margin relative to the figure size. Setting margins too large results in an error otherwise. |
cex |
numeric or NULL, sent to |
prefix |
character string used to add whitespace around the axis label. |
... |
additional parameters are ignored. |
This function takes a vector of axis labels, and the margin where they
will be used, and adjusts the relevant axis margin to accomodate the
label size, up to a maximum fraction of the figure size as defined by
maxFig
.
Labels are assumed to be perpendicular to the axis, for example
argument las=2
when using graphics::text()
.
Note this function does not render labels in the figure, and therefore does not revert axis margins to their original size. That process should be performed separately.
invisible numeric
margin size in inches, corresponding
to the requested margin
from par("mai")
.
Other jam plot functions:
coordPresets()
,
decideMfrow()
,
drawLabels()
,
getPlotAspect()
,
groupedAxis()
,
imageByColors()
,
imageDefault()
,
minorLogTicksAxis()
,
nullPlot()
,
plotPolygonDensity()
,
plotRidges()
,
plotSmoothScatter()
,
shadowText_options()
,
shadowText()
,
showColors()
,
smoothScatterJam()
,
sqrtAxis()
,
usrBox()
xlabs <- paste0("item_", (1:20));
ylabs <- paste0("rownum_", (1:20));
adjustAxisLabelMargins(xlabs, 1);
adjustAxisLabelMargins(ylabs, 2);
nullPlot(xlim=c(1,20), ylim=c(1,20), doMargins=FALSE);
axis(1, at=1:20, labels=xlabs, las=2);
axis(2, at=1:20, labels=ylabs, las=2);
par("mar"=c(5,4,4,2));
adjustAxisLabelMargins(xlabs, 3);
adjustAxisLabelMargins(ylabs, 4);
nullPlot(xlim=c(1,20), ylim=c(1,20), doMargins=FALSE);
axis(3, at=1:20, labels=xlabs, las=2);
axis(4, at=1:20, labels=ylabs, las=2);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.