I am struggling to find a way to change font style and font size of figures in R. I want all text in the figure in Arial 12. I frequently use cex command for increasing and decreasing font but for now I want 12 font size specifically. I am not using any specialized plotting package and just using R base plotting functions, like plot().
I tried installing and using the package extrafont, following this post: Changing Fonts for Graphs in R but it is giving me the following error. I don’t understand why it is saying “could not find function “theme”. I did install and load the package and followed instructions like given in the post.
plot(hfit) +
- theme(text=element_text(family=”Times New Roman”, face=”bold”, size=12))
Error in theme(text = element_text(family = “Times New Roman”, face = “bold”, :
could not find function “theme”
From this post: specifying font size in R figures I thought I may use par(ps=12) for font size 12, but I couldn’t figure out how to exactly use this function. I tried this “plot(hfit, par(ps=12))” but I think this code is wrong.
If someone can please tell me any simple way to get all fonts of figure in Arial 12.
Thank you