问题
According to the comments from others, this post has been separated into smaller questions from the previous version of this OP.
In the graph below, will you help me to
- Close the side=4 (in each Figs. A-D), keeping the labels as it is (to the length as shown) and create minor ticks at secondary axes (side=3 and 4); no.of div=5.
- Why does minor.tick(nx=5,ny=5) produce 6 division in tick for Fig.C
The graph below is produced with the data in pdf device.
Any help with these issues is highly appreciated.(Newbie to R!) Since all the code is too long to post here, I have posted a part relevant to the problem here for Fig.C

#FigC label1=c(0,100,200,300) plot(data$TimeVariable2C,data$Variable2C,axes=FALSE,ylab="",xlab="",xlim=c(0,24), ylim=c(0,2.4),xaxs="i",yaxs="i",pch=19) lines(data$TimeVariable3C,data$Variable3C) axis(2,tick=T,at=seq(0.0,2.4,by=0.6),label= seq(0.0,2.4,by=0.6)) axis(1,tick=T,at=seq(0,24,by=6),label=seq(0,24,by=6)) mtext("(C)",side=1,outer=F,line=-10,adj=0.8) minor.tick(nx=5,ny=5) par(new=TRUE) plot(data$TimeVariable1C,data$Variable1C,axes=FALSE,xlab="",ylab="",type="l", ylim=c(800,0),xaxs="i",yaxs="i") axis(3,xlim=c(0,24),tick=TRUE,at= seq(0,24,by=6),label=seq(0,24,by=6),col.axis="violetred4",col="violetred4") axis(4,tick=TRUE,at= label1,label=label1,col.axis="violetred4",col="violetred4") polygon(data$TimeVariable1C,data$Variable1C,col='violetred4',border=NA)
回答1:
The reason minor.tick
produces 6 intervals is that it was written on the assumption that the default axis divisions would be used. It has no way of knowing that you substituted a different major tick placement.
After each axis(4, ...) call, you should make a call:
box()
I already answered the question yesterday on SO about how to construct a modified version of minor.tick
that could be used with side =3 or =4.
来源:https://stackoverflow.com/questions/17127645/multiple-plots-in-r-with-both-primary-and-secondary-axes-on-all-4-sides-with-cus