我有一些连续的数据:
我正在图上绘制mean_force,如下所示:
x=c(1:2700)
plot(x, mean_force, ty="l", col="blue", ylim=c(-15, 15),
ylab="force (mN)",
xlab='time (ms)',
lty=1,lwd=3)
问题是,如何在下图(均值周围的阴影区域)上绘制标清图?在R中有什么简单的方法吗?
答案 0 :(得分:1)
如果您正在寻找基本的图形解决方案,也许这将对您有用:
#create data
x<-1:100
mean_force<-0.5*x+rnorm(100)
#assume constant standard deviation across the
sd<-5
#determine error band
psd<-mean_force+sd
nsd<-mean_force-sd
plot(x, mean_force, ty="l", col="blue",
ylab="force (mN)",
xlab='time (ms)',
lty=1,lwd=3)
#draw boundary and fill
lines(x, psd)
lines(x, nsd)
polygon(x=c(x, rev(x)), y=c(psd, rev(nsd)), col="lightblue", density = 40, angle=90)
#redraw line on top
lines(x, mean_force, col="blue",lwd=3)