简体   繁体   English

如何删除R中的第二个x和y轴?

[英]How do I remove the second x and y axes in R?

Hopefully a simple question today: 希望今天一个简单的问题:

I'm plotting an RDA (in R Studio) and would like to remove the second X and Y (top and right) axes . 我正在绘制一个RDA(在R Studio中),并希望删除第二个X和Y(顶部和右侧)轴。 Purely for aesthetic purposes, but still. 纯粹出于美学目的,但仍然如此。 The code I'm using is below. 我正在使用的代码如下。 I've managed to remove the first axes (I'll replace them with something nicer later) with xaxt="n" and yaxt="n", but it still puts the others in. 我已经设法删除了第一个轴(我将用更好的东西替换它们),xaxt =“n”和yaxt =“n”,但它仍然将其他轴放入。

The question: How do I remove the top and right axes from a plot in R? 问题:如何从R中的图中移除顶轴和右轴?

To make this example reproducible you will need two data frames of equal length called "bio" and "abio" respectively. 为了使这个例子具有可再现性,你需要两个长度相等的数据帧,分别叫做“bio”和“abio”。

library (vegan) ##not sure which package I'm actually employing
library(MASS)   ##these are just my defaults
rdaY1<-rda(bio,Abio) #any dummy data will do so long as they're of equal length
par(bg="transparent",new=FALSE)
plot(rdaY1,type="n",bty="n",main="Y1. P<0.001 R2=XXX",
     ylab="XXX% variance explained",
     xlab="XXX% variance explained",
     col.main="black",col.lab="black", col.axis="white",
     xaxt="n",yaxt="n",axes=FALSE, bty="n")
abline(h=0,v=0,col="black",lwd=1)
points(rdaY1,display="species",col="gray",pch=20)
#text(rdaY1,display="species",col="gray")
points(rdaY1,display="cn",col="black",lwd=2)
text(rdaY1,display="cn",col="black")

UPDATE: Using comments below I've played around with various ways to get rid of the axes and it seems like that second "points" command where I call for the vectors to be plotted is the problem. 更新:使用下面的评论我已经玩了各种方法来摆脱轴,似乎第二个“点”命令,我呼吁绘制矢量是问题。 Any ideas? 有任何想法吗?

bty="L" worked for me. bty="L"为我工作。 I generated some random data using rnorm() to test: 我使用rnorm()生成一些随机数据来测试:

library(vegan)
mat <- matrix(rnorm(100), nrow = 10)
pl <- rda(mat)
plot(pl, bty="L")

Here's the result. 这是结果。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM