hatmatrix
hatmatrix

Reputation: 44902

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

Upvotes: 0

Views: 280

Answers (1)

hvollmeier
hvollmeier

Reputation: 2986

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.

Upvotes: 1

Related Questions