I would like to specify a font for all text when making a ggplot. I found I can set the base size under ggplot's selected theme but cannot find a clear example of setting to a monospaced font such as say Courier or preferably Roboto Mono for the entire plot.
This solution looked like it should work:
Can't change fonts in ggplot/geom_text
But no joy in my attempt below
install.packages("extrafont")
library(extrafont)
loadfonts(device = "win")
require(tidyverse)
ggplot(mtcars, aes(x = mpg, y = cyl, group = carb))
geom_point()
theme_light(base_size = 15, base_family = "Roboto Mono")
CodePudding user response:
Going along with @Allan Cameron 's response.
windowsFonts('Roboto Mono'=windowsFont("Roboto Mono"))
ggplot(mtcars, aes(x = mpg, y = cyl, group = carb))
geom_point()
theme_light(base_size = 15, base_family = windowsFonts()$`Roboto Mono`)