累積値を示す影付きのリボンで棒グラフを作成したいと思います。
require(ggplot2)
plot_data = data.frame(period=factor(c("t_1", "t_5_to_t_2", "t_8_to_t_2", "t_11_to_t_2", "t_14_to_t_2"), levels=c("t_1", "t_5_to_t_2", "t_8_to_t_2", "t_11_to_t_2", "t_14_to_t_2")), vals = 1:5, ribbon_vals = cumsum(1:5))
ggplot(data=plot_data, aes(x=period, y=vals)) +
geom_bar(stat="identity", colour=c("#6495ED", "#2E8B57", "#2E8B57", "#2E8B57", "#2E8B57")) +
scale_x_discrete(labels = c('t_1' = expression(t-1), 't_5_to_t_2' = expression(t-5 %->% t-2), 't_8_to_t_2' = expression(t-8 %->% t-2), 't_11_to_t_2' = expression(t-11 %->% t-2), 't_14_to_t_2' = expression(t-14 %->% t-2))) +
geom_ribbon(aes(x=1:5, y=ribbon_vals))
これはうまくいかないようです。正しい使い方はgeom_ribbon
?