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)
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()
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
Find the Probability Density of a New Data Point Using "Density" Function in R
Sum Nlayers of a Rasterstack in R
How to Change a Value Coded as "Yes" to a Value of 1 in R
How to Unscale the Coefficients from an Lmer()-Model Fitted with a Scaled Response
Conditional Rolling Mean (Moving Average) on Irregular Time Series
R - Store a Matrix into a Single Dataframe Cell
Adding S4 Dispatch to Base R S3 Generic
Create Category Based on Range in R
R Ggplot Ordering Bars Within Groups
Ggplot2 - Custom Grob Over Axis Lines
How to Get Rmarkdown 1.2 with Microsoft R Open 3.3.2
Speedup Conversion of 2 Million Rows of Date Strings to Posix.Ct
Floating Point Arithmetic and Reproducibility
Getting Frequency Values from Histogram in R
How to Select Columns in Data.Table Using a Character Vector of Certain Column Names
Is Data Really Copied Four Times in R's Replacement Functions