0
votes

I would like to use gap.plot which makes a break in the x axis. But I need to plot three variables. I cannot figure out how to plot all three; my code plots only the last variable...

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

Here is the figure with only one variable:

enter image description here

My data is here: https://www.dropbox.com/s/h8j895hklxeanyr/data1.csv?dl=0

1

1 Answers

1
votes

Try this (use add=TRUE, add ytics and fix 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)))

enter image description here