However if I also use geom_blank before the call to geom_rect the
warnings go away.
Am I doing something "wrong" in the first case that is corrected by
using geom_blank in the second case? I am a little confused as to why
I need to use geom_blank to avoid getting warnings from ggplot2. The
resulting graphs seem indistinguishable to me.
Thanks!
Trevor
My example:
nber.dates <-
structure(list(Start = structure(c(1430, 3683, 4230, 7517, 11413,
13879), class = "Date"), End = structure(c(1915, 3864, 4716,
7759, 11656, NA), class = "Date"), ymin = c(-Inf, -Inf, -Inf,
-Inf, -Inf, -Inf), ymax = c(Inf, Inf, Inf, Inf, Inf, Inf)), .Names = c
("Start",
"End", "ymin", "ymax"), row.names = 28:33, class = "data.frame")
fill = "grey80"
color = NA
size = 0.5
alpha = 0.5
require("ggplot2")
ggp <- ggplot(aes(x=date, y=100*unemploy/pop), data=economics)
# First case
# gives me four warnings of "in min(x) : no non-missing arguments to
min: returning Inf
ggp + geom_rect(aes(xmin = Start, xmax = End, x = NULL, y = NULL,
ymin = ymin, ymax = ymax),
color = color, fill = fill, size = 0.5, alpha = 0.5,
data = nber.dates) + geom_line() + theme_bw()
# Second case
# throwing in a geom_blank() before geom_rect "fixes" the warnings
ggp + geom_blank() +
geom_rect(aes(xmin = Start, xmax = End, x = NULL, y = NULL,
ymin = ymin, ymax = ymax),
color = color, fill = fill, size = 0.5, alpha = 0.5,
data = nber.dates) + geom_line() + theme_bw()
Looks like a bug. I'll add it to my to do list -
http://github.com/hadley/ggplot2/issues/#issue/64
Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
>