从树状图中去除x轴标签

时间:2021-10-16 15:00:47

I use xlab="" to suppress the x-label but still get a 'sub-x-label' in my dendrogram. How can I remove this and remove any extra space under the dendrogram?

我使用xlab="" "来抑制x-label,但仍在dendrogram中得到'sub- label'。我如何删除这个和删除树状图下的任何额外空间?

require(graphics)

hc <- hclust(dist(USArrests), "ave")
plot(hc,xlab="")

从树状图中去除x轴标签

3 个解决方案

#1


19  

To remove the subtitle use the following:

要删除字幕,请使用以下内容:

plot(hc, xlab="", sub="")

To remove the bottom margin (see ?par for details):

移除底部边缘(详见?par):

par(mar=c(0, 4, 4, 2)) # c(bottom, left, top, right)
plot(hc, xlab="", sub="")

#2


4  

May be plot(hc,xlab='', sub="") removes it.

可以是plot(hc,xlab=“,sub=”)删除它。

#3


3  

You need

你需要

op <- par(mar = c(2,4,4,2) + 0.1))
plot(hc, xlab = "", sub = "")
par(op)

The first par() line stores the current settings and then sets the margin to be 2 lines bottom, 4 on the left and top and 2 lines on the right (plus a bit). Then we plot setting an empty string for the *sub*title via argument sub. Finally we set the parameters back to what they were before the first line.

第一个par()行存储当前设置,然后将边界设置为2行底部,4在左边,2行在右边(加一点)。然后,我们将为*子*标题设置一个空字符串,通过参数子。最后,我们将参数设置为在第一行之前。

I left a bit of room on the bottom margin as I'm not sure how far the labels can hand down. Change the first 2 in mar = c(2,4,4,2) to something smaller if you want less space down the bottom.

我在底部空白处留了一点空间,因为我不确定标签能传递到多远。如果你想要减少底部的空间,那么将mar = c(2,4,4,2)的前2改为更小的。

#1


19  

To remove the subtitle use the following:

要删除字幕,请使用以下内容:

plot(hc, xlab="", sub="")

To remove the bottom margin (see ?par for details):

移除底部边缘(详见?par):

par(mar=c(0, 4, 4, 2)) # c(bottom, left, top, right)
plot(hc, xlab="", sub="")

#2


4  

May be plot(hc,xlab='', sub="") removes it.

可以是plot(hc,xlab=“,sub=”)删除它。

#3


3  

You need

你需要

op <- par(mar = c(2,4,4,2) + 0.1))
plot(hc, xlab = "", sub = "")
par(op)

The first par() line stores the current settings and then sets the margin to be 2 lines bottom, 4 on the left and top and 2 lines on the right (plus a bit). Then we plot setting an empty string for the *sub*title via argument sub. Finally we set the parameters back to what they were before the first line.

第一个par()行存储当前设置,然后将边界设置为2行底部,4在左边,2行在右边(加一点)。然后,我们将为*子*标题设置一个空字符串,通过参数子。最后,我们将参数设置为在第一行之前。

I left a bit of room on the bottom margin as I'm not sure how far the labels can hand down. Change the first 2 in mar = c(2,4,4,2) to something smaller if you want less space down the bottom.

我在底部空白处留了一点空间,因为我不确定标签能传递到多远。如果你想要减少底部的空间,那么将mar = c(2,4,4,2)的前2改为更小的。