facet_grid & geom_hline

24 views
Skip to first unread message

Mike Lawrence

unread,
Mar 10, 2009, 9:21:17 PM3/10/09
to ggp...@googlegroups.com
I'm sure this will betray yet another embarrassing misunderstanding of
ggplot2 mechanics, but I'm having troubles adding a different hline to
each panel in a plot:

p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am)

hline.data = data.frame(z=1:4 , vs=c(0,0,1,1), am=c(0,1,0,1))

p+geom_hline(data=hline.data,yintercept=z)
#Error in get("new", env = GeomHline, inherits = TRUE)(GeomHline, ...) :
# object "z" not found

p+geom_hline(data=hline.data,aes(yintercept=z))
#yields lines at zero (as previously reported in this list:
# http://tinyurl.com/anoljh)

--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tinyurl.com/mikes-public-calendar

~ Certainty is folly... I think. ~

hadley wickham

unread,
Mar 14, 2009, 1:01:45 PM3/14/09
to Mike Lawrence, ggp...@googlegroups.com
Hi Mike,

No that's a bug. For how simple they appear, you wouldn't believe how
hard it is to get geom_hline and geom_vline working in every
circumstance.

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages