I am plotting a boxplot without the outliers and I would like to create a new plot in the same cartesian space as the boxplot did. Is there a way of extracting the plotting values for a plot?
I first thought about creating an object but there seems to be no plotting-related parameters.
my_plot <- boxplot(a ~ b, outline=F)
But the parameters inside my_plot only concern statistical information but not plotting.
How can I get the final range (ylim) of the boxplot?
UPDATE: Nick's @nick-sabbe suggestion (par("yaxp")[1:2]
) partially works. It returns properly the value of each of the labels in each extreme on the Y-axis. The correct way is to use par('usr') as it returns the extremes of the plotting area in the form (x1, x2, y1, y2). Thanks Nick for pointing me into the right direction.
I haven't tested this for boxplots, but for normal scatterplots, par("yaxp")
gives you interesting information wrt the y axis. So you can use, IIRC, par("yaxp")[1:2]
to get the current outer limits of the y axis. This doesn't always do exactly what you want, but typically it does. Let us know if it works for your boxplot...
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