Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
795 views
in Technique[技术] by (71.8m points)

plot - R: Titles cut in half with par()

I have this figure:

require(corrplot)
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)
}
par(mfrow = c(1, 1))

which produces titles cut in half:

enter image description here

Following this answer I set oma=c(0,0,2,0) but it does't affect the results. I am not sure which margin I should modify. I looked at ?par and modified "oma", "omd", "omi", "mai", "mar" with no result.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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()

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...