I want to get the xmin and xmax of an existing ggplot
.
But ggplot2
functions like xlim()
only set this, they don't return the value from an existing plot.
Exploring the plot structure using names(p)
and str(p)
shows some candidate helpers (ggproto functions like get_scale() but unclear how these could be used.
Axis limits must be stored when they are set, but I can't see how to access them.
For ease of repro:
p = ggplot2::qplot(wt, mpg, data = mtcars)
# is it possible to access the xmin and xmax from p?