码迷,mamicode.com
首页 > 编程语言 > 详细

R语言画点状误差线

时间:2018-10-02 17:40:08      阅读:292      评论:0      收藏:0      [点我收藏+]

标签:代码实现   col   ima   src   图片   现在   png   std   xxxx   

现在项目需要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语言画点状误差线

标签:代码实现   col   ima   src   图片   现在   png   std   xxxx   

原文地址:https://www.cnblogs.com/marszhw/p/9736626.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!