如何用多个轴通过图解决此问题?
以下代码从此答案,非常有效。
# Plot and first axis:
plot(1:10,1:10,bty="n",col="red",pch=16,axes=FALSE,xlab="",ylab="")
axis(2,0:11,las=1)
axis(1,0:11,line=1,col="red",col.ticks="red",col.axis="red")
mtext("Label 1",1,line=1,at=0.2,col="red")
# Secondary points and axis:
points(rnorm(10,50,20)/10, rnorm(10,5,2),pch=16, col="blue" )
axis(1,0:11,labels=0:11*10,line=3,col="blue",col.ticks="blue",col.axis="blue")
mtext("Label 2",1,line=3,at=0.2,col="blue")
但是,我需要为自己的目的添加更多,并且尝试添加以下块:
points(rnorm(10,50,20)/10, rnorm(10,5,2),pch=16, col="black" )
axis(1,0:11,labels=0:11*10,line=5,col="black",col.ticks="black",col.axis="black")
mtext("Label 3",1,line=5,at=0.2,col="black")
尽管出现第三个图,但第三个轴似乎位于页面以下,但并未完全显示。试图更改参数,但没有运气。
The following code is copied from this Answer, which works perfectly.
# Plot and first axis:
plot(1:10,1:10,bty="n",col="red",pch=16,axes=FALSE,xlab="",ylab="")
axis(2,0:11,las=1)
axis(1,0:11,line=1,col="red",col.ticks="red",col.axis="red")
mtext("Label 1",1,line=1,at=0.2,col="red")
# Secondary points and axis:
points(rnorm(10,50,20)/10, rnorm(10,5,2),pch=16, col="blue" )
axis(1,0:11,labels=0:11*10,line=3,col="blue",col.ticks="blue",col.axis="blue")
mtext("Label 2",1,line=3,at=0.2,col="blue")
However, I need to add one more for my purpose and I tried to add this following chunk:
points(rnorm(10,50,20)/10, rnorm(10,5,2),pch=16, col="black" )
axis(1,0:11,labels=0:11*10,line=5,col="black",col.ticks="black",col.axis="black")
mtext("Label 3",1,line=5,at=0.2,col="black")
Although the third plot appears but the third axis seems to go below the page and do not appear fully. Tried to change the parameters but no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过增加底部边距的线数来为轴创建更多空间。默认值为5,因此您可以尝试将其增加到7。这必须在调用
plot
之前必须完成。有关更多详细信息,请参见PAR
的帮助You can create more space for the axis by increasing the number of lines of the bottom margin. The default value is 5 so you may try increasing it to 7. This has to be done before you call
plot
. See help forpar
for more details