geom_ribbon not working as expected for stacking confidence intervals

705 views Asked by At

I try to plot pre-computed confidence intervals using ggplot.

However there is a problem:

library(ggplot2)
p = ggplot(rawHistoricValues,aes(x=date,y=cumsum(amount)))+geom_line(color = "steelblue")
p + geom_ribbon(data=predictions, aes(ymin=pct05, ymax=pct95)) + geom_ribbon(data=predictions, aes(ymin=pct25, ymax=pct75))

This code results in the error of: Objekt 'amount' not found. The strange thing is, that the first command which plots the historic data does use the amount and does plot it correctly and only the geom_ribbon seems to have problems

This is some part from the data-set

date   pct05   pct25   pct50   pct75   pct95      group
1   2009-07-01 4276.00 4276.00 4276.00 4276.00 4276.00 2010-01-01
2   2009-07-02 4076.00 4076.00 4076.00 4076.00 4076.00 2010-01-01
3   2009-07-03 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
4   2009-07-04 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
5   2009-07-05 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
6   2009-07-06 4699.93 4699.93 4699.93 4699.93 4699.93 2010-01-01
7   2009-07-07 4664.76 4664.76 4664.76 4664.76 4664.76 2010-01-01
8   2009-07-08 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
9   2009-07-09 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
10  2009-07-10 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
11  2009-07-11 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
12  2009-07-12 4627.37 4627.37 4627.37 4627.37 4627.37 2010-01-01
13  2009-07-13 4477.37 4477.37 4477.37 4477.37 4477.37 2010-01-01
14  2009-07-14 4477.37 4477.37 4477.37 4477.37 4477.37 2010-01-01
15  2009-07-15 4030.55 4030.55 4030.55 4030.55 4030.55 2010-01-01
16  2009-07-16 4030.55 4030.55 4030.55 4030.55 4030.55 2010-01-01
17  2009-07-17 4344.58 4344.58 4344.58 4344.58 4344.58 2010-01-01
18  2009-07-18 4344.58 4344.58 4344.58 4344.58 4344.58 2010-01-01
19  2009-07-19 4344.58 4344.58 4344.58 4344.58 4344.58 2010-01-01
20  2009-07-20 4335.68 4335.68 4335.68 4335.68 4335.68 2010-01-01
0

There are 0 answers