On Windows, you can either load fonts into R on the fly with windowsFonts(name_of_font_inside_r = windowsFont("Name of actual font")), or you can use extrafonts::load_fonts() from the extrafonts library to permanently load fonts into R’s internal database. ggsave() on its own cannot correctly save PDF versions of plots with custom fonts-it cannot embed the fonts.įixing both of these issues is relatively easy.R on Windows does not automatically see custom fonts and will throw an error if you try to use them. However, there are a couple difficulties when using custom fonts like this: X = "Cylinders", y = "Highway miles per gallon") theme_light(base_family = "Source Sans Pro") theme(plot.caption = element_text(family = "Source Sans Pro ExtraLight")) Subtitle = "This is an interesting relationship, I guess",Ĭaption = "Source: ggplot's built-in data", P <- ggplot(mpg, aes(x = cyl, y = hwy)) geom_point() geom_smooth(method = "lm") annotate( "text", x = 5, y = 35, label = "There aren't a lot of\n5 cylinder cars",įamily = "Source Sans Pro Semibold", color = "#DC5B44", size = 4) labs(title = "Highway miles per gallon and cylinders",
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |