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

Elizabeth
  • 6,391
  • 17
  • 62
  • 90

3 Answers3

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="")
sgibb
  • 25,396
  • 3
  • 68
  • 74
  • Thank you. The subtitle is aded automatically and I just didn't realise it was a subtitle. – Elizabeth Sep 17 '12 at 16:40
  • 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!!! – Stefano Mar 27 '18 at 08:05
8

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

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
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.

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453