赖江山的博客分享 http://blog.sciencenet.cn/u/laijiangshan 生态、统计与R语言

博文

巧用箭头函数添加误差线

已有 4075 次阅读 2017-3-14 08:49 |系统分类:科研笔记|关键词:学者| 误差线

#在sciplot程序包里可以自动加误差线

install.packages("sciplot")     #安装sciplot包

library(sciplot)                  #调用sciplot包

bargraph.CI(dose, len, data = ToothGrowth)

lineplot.CI(dose, len, data = ToothGrowth)


# 巧用箭头作为误差项方案,其实这个更实用,因为我们可以自己定误差线,或是置信区间的线

x  = 1:5

y  = c(1.1, 1.5, 2.9, 3.8, 5.2)

SD = c(0.1, 0.3, 0.2, 0.2, 0.4)


plot (x, y)

# add error bars (without adjusting yrange)

arrows(x, y-SD, x, y+SD, length=0.05, angle=90, code=3)

# new plot (adjusts Yrange automatically)

plot (x, y,ylim=c(1,6))

arrows(x, y-SD, x, y+SD, length=0.05, angle=90, code=3)




https://m.sciencenet.cn/blog-267448-1039316.html

上一篇:类别变量与哑变量相互转化程序
下一篇:如何去掉数据框带某一字符的行的R代码

1 梅卫平

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 14:09

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部