我想使用gap.plot在x轴上休息。但我需要绘制三个变量。我无法弄清楚如何绘制所有三个;我的代码只绘制了最后一个变量......
library(plotrix)
par(bty="n") # deleting the box
with(subset(data1, mechanism=='Inhibition'),gap.plot(day,BL.P, gap=c(51,116), gap.axis="Time (day)", xlab="Time (days)", ylab="Proportion",pch=16,
col="#0072B2"))
with(subset(data1, mechanism=='Facilitation'), gap.plot(day,BL.P, gap=c(51,116), gap.axis="Time (day)", pch=16,
col="#D55E00"))
with(subset(data1, mechanism=='Total'), gap.plot(day,BL.P, gap=c(51,116), gap.axis="Time (day)", xlab="Time (days)", ylab="Proportion",pch=16,
col="#000000",xtics=c(1,50,119,133)))
abline(v=seq(from=50.5,to=53.5,by=.001), col="white") # hiding vertical lines
这是只有一个变量的图:
我的数据在这里: https://www.dropbox.com/s/h8j895hklxeanyr/data1.csv?dl=0
答案 0 :(得分:0)
试试这个(使用add=TRUE
,添加ytics
并修复ylim
):
ymin <- min(data1$BL.P)
ymax <- max(data1$BL.P)
with(subset(data1, mechanism=='Total'),
gap.plot(day,BL.P, gap=c(51,116), gap.axis="Time (day)",
xlab="Time (days)", ylab="Proportion",pch=16,
col="#000000",xtics=c(1,50,119,133), ytics=c(25,50,75,100), ylim=c(ymin, ymax)))
with(subset(data1, mechanism=='Inhibition'),
gap.plot(day,BL.P, gap=c(51,116), gap.axis="Time (day)",
xlab="Time (days)", ylab="Proportion",pch=16,
col="#0072B2", ytics=c(25,50,75,100), ylim=c(ymin, ymax), add=TRUE))
with(subset(data1, mechanism=='Facilitation'),
gap.plot(day,BL.P, gap=c(51,116), gap.axis="Time (day)", pch=16,
col="#D55E00", add=TRUE, ytics=c(25,50,75,100), ylim=c(ymin, ymax)))