Take the 2-minute tour ×

I am plotting a time series with mean values of a response variable as points (y-axis) by month (x-axis).

Values lying on the x-axis (i.e. 0 values) are clipped. I can change the limits of the y axis to include some padding below 0, but I prefer not to.

Is there a way to plot these 0 points in front of, or on-top of the x-axis?


Matthew![cant post my image...i'm new][1]

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Try this,

q <- qplot(1:10,1:10,size=I(10)) + scale_y_continuous(expand=c(0,0))
gt <- ggplot_gtable(ggplot_build(q))


share|improve this answer
Thanks. I could not get this to work. ggplot_gtable not recognized... –  user1267299 Mar 14 '12 at 18:23
you should update your packages –  baptiste Mar 14 '12 at 18:48
Will do, and try again. Thank you! –  user1267299 Mar 15 '12 at 5:36
Subbing in the following code turns off clipping when faceting: gt$layout$clip[grep("panel",gt$layout$name)] <- "off" –  jslefche May 20 '13 at 17:18
add comment

You can use attribute expand() on the scale_y
Exemple for 10% each side of y scale :

ggplot(mydata, aes(y = value, x = mydate)) +
  geom_point() +
share|improve this answer
Thank you. This works by expanding the range of the y axis. It works nicely, but I would prefer something like that suggested by baptiste above. i.e., the x axis starts at 0, but the 0 points are plotted on-top of it. Thank you for your help, though. –  user1267299 Mar 14 '12 at 18:33
add comment

Use clip().

clip(-0.5, 4.1, -0.5, 4.1)
points(0.85, 1, col = 'red', cex = 2)
share|improve this answer
I couldn't figure out how to make this work within ggplot script. I also tried plotting the figure, then clipping and adding a point on top. But that did not work either. Thanks. –  user1267299 Mar 14 '12 at 18:28
add comment

Your Answer


