[R] ggplot2: bug in geom_ribbon + log scale!?

Martin Rittner kmr at thegeologician.net
Sun Feb 17 20:49:09 CET 2008


Hi everyone, Hadley,

it seems there's a bug in geom_ribbon() when using it in a log-scaled plot:

d<-data.frame(x=c(1:20),y1=rnorm(20)+3,y2=rnorm(20)+5)
p<-ggplot()
p<-p+geom_ribbon(data=d,aes(x=d[["x"]],min=d[["y1"]],max=d[["y2"]]))
p<-p+geom_line(data=d,aes(x=d[["x"]],y=d[["y1"]]),colour="blue")
p<-p+geom_line(data=d,aes(x=d[["x"]],y=d[["y2"]]),colour="red")
p2+scale_y_continuous()

...gives the plot I want, only with my actual data, I'd need it in 
log-scale:

p2+scale_y_log10()

shifts the ribbon far above the actual data (factor 1000, if I see it 
right, but I haven't tested it with different data to check on that...).

I'm using the latest version of ggplot2 (0.5.7).

Has anyone any suggestions for a workaround/patch?

Many Thanks, Martin



More information about the R-help mailing list