Main Title at the Top of a Plot Is Cut Off

Main title at the top of a plot is cut off

R does not by default allocate any space to the outer margins; see par("oma"). Try

par(oma=c(0,0,2,0))

(See ?par and search for "outer" for more information.)

R plot (hclust) and clusplot titles cut off on top

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.

Adjust plot title (main) position

We can use title() function with negative line value to bring down the title.

See this example:

plot(1, 1)
title("Title", line = -2)

Sample Image

R: Titles cut in half with par()

I found that passing mar arguments to corrplot was effective:

    png(height=300,width=600);par(oma=c(0,0,2,0), mfrow = c(1, 3))
for (country in c("Italy","Germany","Afghanistan")) {
corrplot.mixed(cor(data.frame(v1=rnorm(40),
v2=rnorm(40),
v3=rnorm(40),
v4=rnorm(40),
v5=rnorm(40),
v6=rnorm(40),
v7=rnorm(40),
v8=rnorm(40)), use="pairwise.complete.obs"),
main=country, mar=c(0,0,2,0))
};dev.off()

Sample Image

MATLAB Figure Title gets cut off

OK, I found it. In R2010a, it can be fixed by going "File -> Preferences -> Image Processing" and under IMSHOW Display, setting Border Style to Loose. Don't know why I didn't notice this before. Thanks everyone.



Related Topics



Leave a reply



Submit