I am experiencing the similar problems seen in:
and i tried the solutions suggested in both posts.
my code used to plot my hclust:
plot(hclust.train, hang = -1)
here's how my hclust plot look like:
as suggested in the first post mentioned above, i tried:
par(oma=c(0,0,2,0))
to add border padding; however, the plot with the border look like this:
it's simply the cut off version but moved down a bit...
here's how my clusplot plots look like (same problem):
and with the border added:
i've also tried using the argument "mar=c(0,0,2,0)", as suggested in the 2nd post mentioned in the beginning, but the result is the same as adding the border padding.
any help is appreciated.
Edit: Thanks to Ben Bolker for a simple quick solution. After using his suggested code:
par(xpd=NA,oma=c(0,0,2,0))
i got the following improved version:
my last question would be, how to get rid of the border line that's going through the title, OR move the title position above that border line? Thank you!
You didn't give a reproducible example, but I can reproduce this if I set my margins to all-zero; I can work around it with par(xpd=NA)
hc <- hclust(dist(USArrests), "ave")
plot(hc) ## looks OK
Setting the margins to zero cuts off the title:
par(mar=c(0,0,0,0))
plot(hc) ## cut off
Setting the outer margin doesn't help:
par(mar=c(0,0,0,0),oma=c(0,0,2,0))
plot(hc)
Setting par(xpd=NA)
does help:
par(mar=c(0,0,0,0),xpd=NA)
plot(hc)
If I add box()
I get a border line that cuts through the title. The best thing would be to not set the margins to zero, or to set par(mar=c(0,0,2,0))
to make sure there's room for the title at the top, or to use par(oma=c(0,0,2,0))
and then use mtext()
to add the title by hand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With