Skip to content
Prev 262840 / 398502 Next

plot with two y axes BUT unaligned x axis

On 06/15/2011 09:51 PM, bjmjarrett wrote:
Hi Ben,
This might do what you want:

collection_dates<-as.Date(paste(sort(sample(1:30,15)),"05","2011",sep="/"),
  "%d/%m/%Y")
release_dates<-as.Date(paste(sort(sample(1:30,15)),"05","2011",sep="/"),
  "%d/%m/%Y")
release_n<-sample(50:100,15)
collect_n<-sample(50:100,15)
xtickpos<-as.numeric(as.Date(paste(c(1,10,20,30),"05","2011",sep="/"),"%d/%m/%Y"))
xticklab<-format(as.Date(paste(c(1,10,20,30),"05","2011",sep="/"),"%d/%m/%Y"))
library(plotrix)
twoord.plot(sort(collection_dates),collect_n,sort(release_dates),release_n,
  lylim=c(45,105),rylim=c(45,105),xlab="Date",
  ylab="Parasitoids collected",main="Collect/Release",
  rylab="Parasitoids released",xtickpos=xtickpos,xticklab=xticklab)
legend(as.numeric(as.Date("1/5/2011","%d/%m/%Y")),55,
  c("Collection","Release"),lty=1,col=1:2,pch=1:2)

Jim