R语言画点状误差线
Posted marszhw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了R语言画点状误差线相关的知识,希望对你有一定的参考价值。
现在项目需要R语言做几个线性拟合,画一些点图,突然需要画误差线,网上找了下,可以用代码实现。。效果如下
xx1<-c(xxxxxx,xxxx,xxxxx)
yy1<-c(xxxxxx,xxxx,xxxxx)
std1<-c(xxxxxx,xxxx,xxxxx)
std2<-c(xxxxxx,xxxx,xxxxx)
plot_stdy <- function(x, y, sd, len = 1, col = "black") {
len <- len * 0.05
arrows(x0 = x, y0 = y, x1 = x, y1 = y - sd, col = col, angle = 90, length = len)
arrows(x0 = x, y0 = y, x1 = x, y1 = y + sd, col = col, angle = 90, length = len)
}
plot_stdx <- function(x, y, sd, len = 1, col = "black") {
len <- len * 0.05
arrows(x0 = x, y0 = y, x1 = x-sd, y1 =y , col = col, angle = 90,length = len)
arrows(x0 = x, y0 = y, x1 = x+sd, y1 =y, col = col , angle = 90,length = len)
}
plot(xx1,yy1)
plot_stdy(xx1, yy1, sd = std2)
plot_stdx(xx1, yy1, sd = std1)
以上是关于R语言画点状误差线的主要内容,如果未能解决你的问题,请参考以下文章