Is it possible to get the axis limits for the current plot in R? How?
Preferably in the standard base library (I don't like to use ggplot
etc., but these solutions are also welcome).
To change the axis scales on a plot in base R Language, we can use the xlim() and ylim() functions. The xlim() and ylim() functions are convenience functions that set the limit of the x-axis and y-axis respectively.
axis( limits ) specifies the limits for the current axes. Specify the limits as vector of four, six, or eight elements. example. axis style uses a predefined style to set the limits and scaling.
The xlim() function with the provided parameters as the range of the x-axis in vectors is used to set the x-axis without dropping any data of the given plot or an object accordingly. Parameters: …: if numeric, will create a continuous scale, if factor or character, will create a discrete scale.
ylim( limits ) sets the y-axis limits for the current axes or chart.
par("usr")
That ought to do it; see ?par
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With