How do I plot the confidence interval when I provide the C.I. values

后端 未结 1 1041
一个人的身影
一个人的身影 2021-01-22 00:29

I am NOT plotting from the actual data, I only have a data.frame that list the x, y values as well as the upper and lower confident intervals. I want to plot line graph with con

相关标签:
1条回答
  • 2021-01-22 01:10

    You're looking for geom_ribbon. Calling your data frame df:

    ggplot(df, aes(x = x, y = y, group = factor(grp),
                   color = factor(grp), fill = factor(grp))) +
        geom_ribbon(aes(ymax = conf.high, ymin = conf.low), alpha = 0.2) +
        geom_line()
    

    It will be a little cleaner if grp is already a factor.

    0 讨论(0)
提交回复
热议问题