3

I would like to know whether it's possible to change the font of axis labels in a base R plot. I know it can be done with ggplot using the package extrafont, but my plots are already done in base and I would not like to start over due to this minor issue.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
David
  • 371
  • 2
  • 13
  • The ```WindowsFonts()``` soultion did not do the job while the others apply only to ```ggplo2``` – David Sep 16 '19 at 16:09
  • Are you using Windows or another operating system? – G5W Sep 16 '19 at 16:11
  • @GSW i am using Windows 10 – David Sep 16 '19 at 16:13
  • 1
    I tried to edit for a bit of clarity. I think **you'll need to provide additional details** - there is an answer for base plots on Windows at d.b's link - it works for me. So now it becomes a question of *why doesn't that answer work for you?* Can you confirm that [the sample code in this answer](https://stackoverflow.com/a/27694671/903061) does not work for you? Or does that work but you run into trouble when you try to use it on one of your plots? Or maybe it works with Times New Roman, but you want a different font? – Gregor Thomas Sep 16 '19 at 16:38
  • Possible duplicate of [Changing Fonts for Graphs in R](https://stackoverflow.com/questions/27689222/changing-fonts-for-graphs-in-r) – shs Sep 16 '19 at 16:45

1 Answers1

3

you could use the par() before each plot like the following:

par(family = "Ariel Black")
boxplot(dados_final$ytot.n ~ dados_final$ano.f, col = "lightblue", xlab = "Ano", ylab = "Score", main = "Evolution", border = "darkblue")

This will set the font of the plot, depend on the family type

The box plot is just an illustration of the use

David
  • 8,113
  • 2
  • 17
  • 36