如何在R中创建带有误差裕度的折线图 [英] How to create line chart with Margins of Error in R
本文介绍了如何在R中创建带有误差裕度的折线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种方法来绘制随时间变化的人口比例数据,并显示边距或误差,类似于以下示例: http://goo.gl/dbrbu .但找不到任何说明.谢谢!
I am looking for a way to plot data on population proportion over time, with showing margins or error, similar to this example: http://goo.gl/dbrbu. But could not find any instructions on that. Thanks!
推荐答案
一种ggplot2
解决方案:
我将在R中使用美国人口数据集:
I'm going to use the US population dataset in R:
population <- data.frame(Year=seq(1790, 1970, length.out=length(uspop)),
Population=uspop,
Error=rnorm(length(uspop), 5))
library(ggplot2)
ggplot(population, aes(x=Year, y=Population,
ymin=Population-Error, ymax=Population+Error))+
geom_line(colour="red", size=1.2)+
geom_point(pch=2)+
geom_errorbar(width=0.9)
这篇关于如何在R中创建带有误差裕度的折线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文