1

I'd like to set the font for geom_text to Roboto condensed.

I tried to do it wih hrbrbr themes, but it doesn't appear to be in roboto condensed.

I know this thread has an answer, but it requires changing the font system wide.

Can I apply roboto condensed to a ggplot chart for only the geom_text labels?

Cauder
  • 2,157
  • 4
  • 30
  • 69

1 Answers1

1

I don't think the answer you have linked does change the font system-wide. It just gives you the ability to access a font. I'll demonstrate here using a handwriting font to make this very obvious:

windowsFonts(Script = windowsFont("Edwardian Script ITC"))

library(ggplot2)

ggplot(mtcars, aes(disp, mpg)) + 
  geom_text(aes(label = rownames(mtcars)), family = "Script") 

You can see the axis labels and markers are not affected.

Created on 2020-05-15 by the reprex package (v0.3.0)

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87