Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用errbar绘制多个数据集?_R - Fatal编程技术网

如何使用errbar绘制多个数据集?

如何使用errbar绘制多个数据集?,r,R,这就是我到目前为止所做的 library(Hmisc) m1 <- read.table("mt7.1r1.rp", header = FALSE) m2 <- read.table("mt7.1r2.rp", header = FALSE) m3 <- read.table("mt7.2r1.rp", header = FALSE) m4 <- read.table("mt7.2r2.rp", header = FALSE) p1=m1[1] per1=log

这就是我到目前为止所做的

library(Hmisc)

m1 <- read.table("mt7.1r1.rp", header = FALSE) 
m2 <- read.table("mt7.1r2.rp", header = FALSE) 
m3 <- read.table("mt7.2r1.rp", header = FALSE) 
m4 <- read.table("mt7.2r2.rp", header = FALSE)

p1=m1[1]
per1=log10(p1)
ixxr=m1[3]
ixxi=m1[4]

p2=m2[1]
per2=log10(p2)
ixyr=m2[3]
ixyi=m2[4]

p3=m3[1]
per3=log10(p3)
iyxr=m3[3]
iyxi=m3[4]

p4=m4[1]
per4=log10(p4)
iyyr=m4[3]
iyyi=m4[4]

erxx=m1[5]
erxy=m2[5]
eryx=m3[5]
eryy=m4[5]

xmin <- floor(min(per1,per2,per3,per4))
xmax <- ceiling(max(per1,per2,per3,per4))

ymin <- floor(min(ixxr,ixxi))
ymax <- ceiling(max(ixxr,ixxi))

per1=unname(per1)
ixxr=unname(ixxr)
ixxi=unname(ixxi)
erxx=unname(erxx)

per1=unlist(per1)
ixxr=unlist(ixxr)
ixxi=unlist(ixxi)
erxx=unlist(erxx)

errbar(per1,ixxr,ixxr+erxx,ixxr-erxx,col='red',xlabel='Per (s)',ylabel='Zxx/Zxy')
par(new = T)
errbar(per1,ixxi,ixxi+erxx,ixxi-erxx,col='green')
库(Hmisc)

m1将
yaxt='n'
添加到两个图中的一个(我为第一个图添加了它)不报告y轴。如果只有一个y标签,请先使用
ylab=NA
,然后在第二个绘图中设置y标签(或反之亦然)

计算y值的公共范围并通过
ylim
进行设置是一种很好的做法,以确保所有内容都显示在绘图上

errbar(per1,ixxr,ixxr+erxx,ixxr-erxx,col='red', xlab='Per (s)', 
       yaxt = 'n', ylab = NA)

errbar(per1,ixxi,ixxi+erxx,ixxi-erxx,col='green', ylab = 'ixxr and ixxi')