Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!require(showtext)) {
- install.packages("showtext", repos = "http://cran.utstat.utoronto.ca/")
- require(showtext)
- }
- font_add_google("Karla", "karla") # Add nice google font
- showtext_auto() # Tell R to use showtext to render google font
- if (!require(extrafont)) {
- install.packages("extrafont", repos = "http://cran.utstat.utoronto.ca/")
- require(extrafont)
- }
- font_import(pattern = "Karla")
- theme_map <- function(...) {
- theme_minimal() +
- theme(
- text = element_text(family = "Karla", color = "#22211d"),
- panel.grid.minor = element_blank(),
- panel.grid.major = element_blank(),
- plot.background = element_rect(fill = "#f5f5f2", color = NA),
- panel.background = element_rect(fill = "#f5f5f2", color = NA),
- legend.background = element_rect(fill = "#f5f5f2", color = NA),
- panel.border = element_blank(), # infuriatingly doesn't work but that's unrelated
- aspect.ratio = 9 / 16, # 16:9 aspect ratio
- ...
- )
- }
- data(iris)
- p <- ggplot() + geom_point(data=iris, aes(x=iris$Sepal.Length, y=iris$Sepal.Width)) + labs(title="Font Pls") + theme_map()
- plot(p)
Add Comment
Please, Sign In to add comment