possible bug in geom_ribbon

Posted by tomw on Stack Overflow See other posts from Stack Overflow or by tomw
Published on 2012-10-28T04:57:18Z Indexed on 2012/10/28 5:00 UTC
Read the original article Hit count: 296

Filed under:
|

i was hoping to plot two time series and shade the space between the series according to which series is larger at that time.

here are the two series-- first in a data frame with an indicator for whichever series is larger at that time

d1 <- read.csv("https://dl.dropbox.com/s/0txm3f70msd3nm6/ribbon%20data.csv?dl=1")

And this is the melted series.

d2 <- read.csv("https://dl.dropbox.com/s/6ohwmtkhpsutpig/melted%20ribbon%20data.csv?dl=1")

which I plot...

ggplot() + geom_line(data = d2,
                 aes(x = time, y = value, group = variable, color = variable)) +
         geom_hline(yintercept = 0, linetype = 2) +
         geom_ribbon(data = d1[d1$big == "B",],
                     aes(x = time, ymin = csa, 
                         ymax =  csb),
                         alpha  = .25,
                         fill = "#9999CC") +
         geom_ribbon(data = d1[d1$big == "A",],
                     aes(x = time, ymin = csb, 
                         ymax =  csa),
                     alpha  = .25,
                     fill = "#CC6666") +
         scale_color_manual(values = c("#CC6666" , "#9999CC"))

which results in...

the resulting plot

why is there a superfluous blue band in the middle of the plot?

© Stack Overflow or respective owner

Related posts about r

    Related posts about ggplot2