Is there a method for specifying the font size in when producing figures in R. This seems like a really basic requirement but I can’t seem to find any references to somewhere that specifies the font size. I can save a figure to a pdf as follows:
setwd("C:\\")
pdf(file="Plot.pdf",family="Times")
plot(x,y);
dev.off()
Where R basically generates the figure in the pdf not in the figure window. When I look for ways of altering the font size all I see is people referring to cex=1.5 argument to scale fonts 150 percent, and cex.lab, cex.axis, etc … Although not being an immediate issue now, I do wonder what will happen when I publish some results and the journal requires font size between 9 and 11. How do I control these in R? Any suggestions would be appreciated.
You control the font size with the
ps(point size) parameter. The default is typically12(but can be controlled globally for a PDF file by thepointsizeparameter) so if you want, let’s say, fonts of the size10for a particular text you would usepar(ps=10); text(...). Since you mentionedcex: note thatcexis relative to the current pointsize and also applies to symbols whereaspsspecifically applies to text. Obviously, the size will only match as long as you don’t resize the resulting figure.