Any ideas on how to calibrate cex to font size units?
Specifically, I'd like to work with the default family 'Helvetica' and specify font sizes to correspond to .doc font sizes. For example, use font size 12 for main titles and font size 10 for axis titles.
I'd appreciate your advise and suggestions. thanks!
How to change font size in r? To change the font size of text, use cex (character expansion ratio). The default value is 1. To reduce the text size, use a cex value of less than 1; to increase the text size, use a cex value greater than 1.
The font-size property is specified in one of the following ways: As one of the absolute-size, relative-size or math keywords. As a <length> or a <percentage> , relative to the element's font size.
You can set the default font on a plot by plot basis.
par(family = 'Helvetica')
plot(rnorm(10), main = 'Something In Helvetica')
There is also a par('font')
that you can use to set whether the font is bold, italic, etc. For the size, besides the cex group of parameters mentioned by Brandon that allow one to set the font size as a relative term, there is also cin, cra, and I believe more that allow one to set sizes in inches or in pixels. Unfortunately, you can't specify in a standard font size of 10 or 12.
Check the help for par()
and read it very carefully.
Your first question requires a bit of heavy lifting. There is a good set of instructions here: http://www.jameskeirstead.ca/typography/changing-the-fonts-in-r-plots/ I'm not aware of an "easier way". But I'd love to see one.
For your second question: See ?par
specifically the part about cex.
cex
cex.axis
cex.lab
cex.main
Additionally, you can mess with the pointsize
setting in ?pdf
to adjust the relative sizes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With