
--
--
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/d/optout.
ggplot(mtcars) +
geom_point(aes(x = hp, y = wt)) +
geom_vline(xintercept = 150) +
geom_hline(yintercept = 3) +
annotate("rect", xmin = 150, xmax = 340, ymin = 3, ymax = 5.6, fill = "darkgreen", alpha = .3) +
scale_x_continuous(expand=c(0,0)) +
scale_y_continuous(expand=c(0,0))
This solution is not ideal as the result has a couple of points plotting on the axes, so a KLUDGEd solution to that issue that I came up with is as follows:
x.min <- min(mtcars$hp)
x.min <- x.min - 0.1*x.min
y.min <- min(mtcars$wt)
y.min <- y.min - 0.1*y.min
ggplot(mtcars) +
geom_point(aes(x = hp, y = wt)) +
geom_vline(xintercept = 150) +
geom_hline(yintercept = 3) +
annotate("rect", xmin = 150, xmax = 340, ymin = 3, ymax = 5.6, fill = "darkgreen", alpha = .3) +
scale_x_continuous(limits=c(x.min,340),expand=c(0,0)) +
scale_y_continuous(limits=c(y.min,5.6),expand=c(0,0))
Maybe someone else here will provide a more elegant solution?
Hope this helps-Allen
______________________________________
Allen Bingham
Bingham Statistical Consulting
LinkedIn Profile: www.linkedin.com/pub/allen-bingham/3b/556/325
--