[R] geom_hline

Jim Lemon jim at bitwrit.com.au
Tue Dec 25 10:16:06 CET 2007

Felipe Carrillo wrote:
>  Hi all:
> I am trying to draw a horizontal line along the zero
> "Y axis" value but since zero isn't showing therefore
> the line is not drawn. If I set my intercept to 15
> then it'll work but I dont want to hardcode it because
> the Y axis parameters could be different for another
> variable. I would like to alway set my hline along the
> zero as default. Thanks
> p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point()
> p + geom_hline(intercept=0)
Hi Felipe,
It sounds like you want to include zero in the axis. In base graphics, 
you would use:


where maxy specifies the upper end of the ordinate. I had a quick look 
at the ggplot2 docs, but I haven't yet found whether this works in that 


More information about the R-help mailing list