From this page I have come to understand that:
font.main=4
will give me a italic bold title for my figure. However I want neither but a plain-old-sans-serif font. More generally I have been looking for a table of what values does what but not found any so far. Is there one and if so where can I see it?
?par
has
‘font’ An integer which specifies which font to use for text. If possible, device drivers arrange so that 1 corresponds to plain text (the default), 2 to bold face, 3 to italic and 4 to bold italic. Also, font 5 is expected to be the symbol font, in Adobe symbol encoding. On some devices font families can be selected by ‘family’ to choose different sets of 5 fonts.
All of which applies to font.main
. Compare:
> layout(1:2)
> plot(1:10, font.main = 1, main = "Foo") ## plain font
> plot(1:10, main = "Foo") ## default bold font
> layout(1)
which gives:
There are two relevant parameters that govern the font. font
and family
. You may want to change family
instead of font
.
From Quick-R on graphical parameters:
font: Integer specifying font to use for text. 1=plain, 2=bold, 3=italic, 4=bold italic, 5=symbol
...
family: font family for drawing text. Standard values are "serif", "sans", "mono", "symbol". Mapping is device dependent.
Furthermore:
In windows, mono is mapped to "TT Courier New", serif is mapped to"TT Times New Roman", sans is mapped to "TT Arial", mono is mapped to "TT Courier New", and symbol is mapped to "TT Symbol" (TT=True Type). You can add your own mappings.
# Type family examples - creating new mappings
plot(1:10,1:10,type="n")
windowsFonts(
A=windowsFont("Arial Black"),
B=windowsFont("Bookman Old Style"),
C=windowsFont("Comic Sans MS"),
D=windowsFont("Symbol")
)
text(3,3,"Hello World Default")
text(4,4,family="A","Hello World from Arial Black")
text(5,5,family="B","Hello World from Bookman Old Style")
text(6,6,family="C","Hello World from Comic Sans MS")
text(7,7,family="D", "Hello World from Symbol")
see also ?par
.
Side note: Quick R, especially the stuff on Graphics, is a great resource for a lot of R related information.
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