简体   繁体   中英

R base graphics: How to set size of text/graphic elements?

I want to create two figures, for instance:

pdf("figures/test1.pdf",width=14,height=14)
par(mfrow=c(2,2))
plot(1:10)
plot(runif(10))
plot(1:10)
plot(rnorm(10))
dev.off()

pdf("figures/test2.pdf",width=7,height=7)
par(mfrow=c(1,1))
plot(rnorm(10))
dev.off()

and I want the font and box sizes for each plot to be the same. In the current call, the font sizes for the first case are much smaller than the second. I will attach an example below for the png graphics device where everything is the same except I have set png(...,units="in",res=96)

TEST1

TEST2

If printing graphics with the pdf-format notice that as a consequence of the figure being larger/smaller the fonts remain the same size , resulting them appearing smaller or larger now when we include the figure in the same area on the printed page. Often a bit of trial and error is required to get the dimensions right. Notice though that increasing the fig.width= , and/or increasing the fig.height=, effectively also reduces the font size. Actually, the font size remains constant whilst the figure grows (or shrinks) in size. Sometimes it is better to reduce the fig.width or fig.height to retain a good sized font.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM