[bug] wrong limits in scale_y_continous for lines plot drops data points

7 views
Skip to first unread message

ido

unread,
Jul 22, 2009, 7:59:47 AM7/22/09
to ggplot2
Hi,
when doing a line plot and setting limits that exclude some data
points the line gets broken.
example:

library("ggplot2")
values <- data.frame(pos=1:7,y=c(1,1,1,5,1,1,1))
p <- ggplot(data=values,aes(x=pos,y=y)) + geom_line() +
scale_y_continuous(limits=c(0,4))
p

I would have expected to see a line going up and down again without of
course seeing the tip.

best,
ido

hadley wickham

unread,
Jul 22, 2009, 8:27:20 AM7/22/09
to ido, ggplot2
Hi Ido,

This isn't a bug, it's the way scales work. You probably want +
coord_cartesian(ylim = c(0, 4))

Hadley
--
http://had.co.nz/

ido

unread,
Jul 22, 2009, 11:06:01 AM7/22/09
to ggplot2

Oh I see!
thank you very much,
ido
Reply all
Reply to author
Forward
0 new messages