I am trying to create a bar plot using ggplot() function. I have this data frame:
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
I want to show for every Leadtime its three respective values (25-75%, 5-95%, Out of confidence Band) in bars. So at the end I will have 6 group of bars.
Thanks in advance guys!
It's not entirely clear if you want stacked bars, if so - here you go. I changed the shape of the dataframe to make plotting easier.
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')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.