The argument expand = in scale_*_continuous() controls the padding;
setting expand = c(0, 0) removes it. If you don't want points, don't
use geom_point(). Here's the simplest way I know of to reproduce your
plot sans the point:
nofly <- data.frame(x=c(-1, -1, 3, 3, -1, -1, 3, 3),
y=c(-1, 0, 0, -1, 1, 2, 2, 1),
id=rep(1:2, each=4))
library(ggplot2)
ggplot() +
geom_polygon(data=nofly, fill="red", alpha=0.3,
aes(x = x, y = y, group=id)) +
scale_y_continuous("Probability", expand = c(0, 0)) +
scale_x_continuous(expand = c(0, 0)) +
geom_abline(intercept=0.2, slope=0.8, size = 1)
The aesthetics you want are in nofly, so you can define them in the
geom_polygon() layer. It is legitimate to pass an empty argument list
to ggplot(), which will set up an empty base layer. Since
geom_abline() doesn't explicitly need a data frame when the intercept
and slope are vectors of length 1 (i.e., they are set rather than
mapped), you have everything you need. All I did was add a size
argument to geom_abline() to make it a bit thicker.
The following also works because geom_abline() doesn't use any of the
aesthetics defined in the ggplot() call and only one data frame is in
play:
ggplot(data=nofly, aes(x = x, y = y, group=id)) +
geom_polygon( fill="red", alpha=0.3) +
scale_y_continuous("Probability", expand = c(0, 0)) +
scale_x_continuous(expand = c(0, 0)) +
geom_abline(intercept=0.2, slope=0.8, size = 1)
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/d/optout.