R gap.plot(x轴断开):如何添加带有箭头()的错误条?可能吗?
我想使用arrows()并在使用gap.plot创建的图形上添加错误条。这很好,但仅适用于轴断开之前的数据。如何为轴断开后的数据添加缺失的错误条? 我的代码:R gap.plot(x轴断开):如何添加带有箭头()的错误条?可能吗?,r,R,我想使用arrows()并在使用gap.plot创建的图形上添加错误条。这很好,但仅适用于轴断开之前的数据。如何为轴断开后的数据添加缺失的错误条? 我的代码: library(plotrix) par(bty="n") # deleting the box ymin <- 0.25 ymax <- 1 with(subset(mydata, mechanism=='Facilitation'), gap.plo
library(plotrix)
par(bty="n") # deleting the box
ymin <- 0.25
ymax <- 1
with(subset(mydata, mechanism=='Facilitation'),
gap.plot(day,mean, gap=c(51,116), gap.axis="Time (day)",
xlab="Time (days)", ylab="(mm)",pch=16,
col="#D55E00",xtics=c(1,50,119,133), ytics=c(0.25,0.5,0.75,1), ylim=c(ymin, ymax)))
with(subset(mydata, mechanism=='Inhibition'),
gap.plot(day,mean, gap=c(51,116), gap.axis="Time (day)",
xlab="Time (days)", ylab="(mm)",pch=16,
col="#0072B2", ytics=c(0.25,0.5,0.75,1), ylim=c(ymin, ymax), add=TRUE))
abline(v=seq(from=50.5,to=53.5,by=.001), col="white") # hiding vertical lines
## error bars
with(subset(mydata, mechanism=='Facilitation'), arrows(day, mean-se, day, mean+se, length=0.05, angle=90, code=3))
with(subset(mydata, mechanism=='Inhibition'), arrows(day, mean-se, day, mean+se, length=0.05, angle=90, code=3))
库(plotrix)
par(bty=“n”)#删除方框
ymin有人帮我解决了这个问题,所以我分享了答案
必须调整“日”值,然后根据这些新值分别绘制较高和较低数据点的误差条
#create new column in data that has adjusted day values
mydata$adjusted_day = mydata$day - 65
## error bars for lower day data points
with(subset(mydata, mechanism=='Facilitation'), arrows(day, mean-se, day,mean+se, length=0.05, angle=90, code=3))
with(subset(mydata, mechanism=='Inhibitionn'), arrows(day, mean-se, day, mean+se, length=0.05, angle=90, code=3))
##error bars for higher day data points
with(subset(mydata, mechanism=='Facilitation'), arrows(adjusted_day, mean-se, adjusted_day, mean+se, length=0.05, angle=90, code=3))
with(subset(mydata, mechanism=='Inhibition'), arrows(adjusted_day, mean-se, adjusted_day, mean+se, length=0.05, angle=90, code=3))