Removing x-axis label from dendrogram in r
Asked Answered
G

3

13

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?

require(graphics)

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

enter image description here

Gorge answered 17/9, 2012 at 16:3 Comment(1)
use plot(hc,xlab=NA, sub=NA), as explained in the help page for ?plot.hclustFleur
I
27

To remove the subtitle use the following:

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

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

par(mar=c(0, 4, 4, 2)) # c(bottom, left, top, right)
plot(hc, xlab="", sub="")
Impaste answered 17/9, 2012 at 16:8 Comment(2)
Thank you. The subtitle is aded automatically and I just didn't realise it was a subtitle.Gorge
give this man some bacon (or chocolate, or whatever else he fancies), for he solved my struggling of a very long time (more than I will be ever happy to admit). Thank you, kind stranger!!!Droll
I
8

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

Imperfective answered 17/9, 2012 at 16:6 Comment(0)
H
4

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.

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.

Hiedihiemal answered 17/9, 2012 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.