Here's an example using a data frame I picked up from another thread
somewhere. To keep it simple, let's just do a scatterplot and find the
bounds of the x- and y-scales in the original coordinate system. The
.05 offsets come from the default value of the expand = argument in
both scale_x_continuous() and scale_y_continuous().
DF <- structure(list(x = c(43, 22, 53, 21, 13, 53, 23, 12, 32), y = c(42,
65, 23, 45, 12, 22, 54, 32, 12)), .Names = c("x", "y"), row.names = c(NA,
-9L), class = "data.frame")
p <- ggplot(DF, aes(x = x, y = y)) + geom_point()
pp <- ggplot_build(p)
> pp$panel$ranges[[1]]$x.range
[1] 9.95 55.05
> pp$panel$ranges[[1]]$y.range
[1] 9.35 67.65
To see how I found this, start with
str(pp)
str(pp$panel)
str(pp$panel$ranges)
and go from there.
Dennis
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
>
https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email
ggp...@googlegroups.com
> To unsubscribe: email
ggplot2+u...@googlegroups.com
> More options:
http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
ggplot2+u...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>