简体   繁体   English

R plot 置信区间直接来自数据,无需计算

[英]R plot confidence interval directly from data, no calculation needed

How can I add confidence interval bars to a scatterplot?如何将置信区间条添加到散点图中?

My dataframe looks like this:我的 dataframe 看起来像这样:

Year   Estimate   LowerCI    UpperCI
2010   1000       750        1250
2020   2000       1500       2500

And I have made a scatterplot as follow:我做了一个散点图如下:

分散

How can I add confidence interval bars to my plot just use information given in the dataframe?如何仅使用 dataframe 中提供的信息向我的 plot 添加置信区间条?

ggplot(data, aes(x = as.factor(Year), y = Estimate, ymin = LowerCI, ymax = UpperCI)) +
  geom_pointrange()

You could also use geom_errorbar() , geom_crossbar() , or geom_linerange() : https://ggplot2.tidyverse.org/reference/geom_linerange.html您也可以使用geom_errorbar()geom_crossbar()geom_linerange()https://ggplot2.tidyverse.org/reference/geom_linerange.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM