R中的所有4边的主轴和副轴都有自定义轴标签 [英] Multiple plots in R with both primary and secondary axes on all 4 sides with custom axis label
问题描述
在下面的图表中,你会帮助我
- 关闭边= 4(在每张图AD中),将标签保持原样(至所示的长度)并在辅助轴上创建次要滴答声(边= 3和4);
- 为什么minor.tick(nx = 5,ny = 5)为图C中的勾号产生6个分割
下面的图表是用 data in pdf device。
对这些问题的任何帮助都非常感谢。(Newbie to R!)由于所有代码都太长,无法在这里发布,所以我发布了一个与图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)
行(data $ TimeVariable3C,data $ Variable3C)
轴(2,tick = T,at = seq(0.0,2.4,by = 0.6),label = seq(0.0,2.4,by = 0.6))
轴(1,tick = T,at = seq(0,24,by = 6),label = seq(0,24,by = 6))
mtext((C),side = 1 ,外= F,线= -10,adj = 0.8)
minor.tick(nx = 5,ny = 5)
par(new = TRUE)
plot数据$ TimeVariable1C,数据$ Variable1C,轴= FALSE,xlab =,ylab =,type =l,
ylim = c(800,0),xaxs =i,yaxs = (0,24,by = 6),label = seq(0,24,by = 6),b = b(3,xlim = c(0,24),tick = TRUE) col.axis =violetred4,col =violetred4)
轴(4,tick = TRUE,at = label1,label = label1,col.axis =violetred4,col =violetred4)
polygon(data $ TimeVariable1C,data $ Variable1C,col ='violetred4',border = NA)
在每个坐标轴(4,...)调用后,你应该打一个电话:
box()
我昨天已经回答了关于如何构建可以与side = 3或= 4一起使用的 minor.tick
的修改版本的问题。
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)
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.
这篇关于R中的所有4边的主轴和副轴都有自定义轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!