我正在尝试使用ggplot()函数创建条形图。我有这个数据框:
25% - 75% 5% - 95% Out of Confidence Band leadtime
1 49.91055 89.80322 10.196780 2 hr
2 50.08945 89.80322 10.196780 12 hr
3 49.73166 89.80322 10.196780 24 hr
4 49.91055 90.16100 9.838998 32 hr
5 50.08945 89.80322 10.196780 50 hr
6 49.73166 89.62433 10.375671 62 hr
我想在每个Leadtime中显示它的三个相应值(25-75%,5-95%,超出信任范围)。所以最后我会有6组酒吧。
先谢谢你们!
答案 0 :(得分:0)
目前还不完全清楚你是否想要叠条,如果是这样的话 - 你走了。我改变了数据框的形状,使绘图更容易。
dat <- data.frame(leadtime = rep(c(2,12,24,32,50,62),each=3),
percent = rep(c("25-75","5-95", "OoC"), 6),
value = c(49.91055, 89.80322, 10.196780,50.08945, 89.80322, 10.196780,
49.73166, 89.80322, 10.196780, 49.91055, 90.16100, 9.838998, 50.08945,
89.80322, 10.196780, 49.73166, 89.62433, 10.375671))
ggplot(dat, aes(leadtime, value, fill = percent))+geom_bar(stat='identity')