Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. if (!require(showtext)) {
  2. install.packages("showtext", repos = "http://cran.utstat.utoronto.ca/")
  3. require(showtext)
  4. }
  5. font_add_google("Karla", "karla") # Add nice google font
  6. showtext_auto() # Tell R to use showtext to render google font
  7.  
  8. if (!require(extrafont)) {
  9. install.packages("extrafont", repos = "http://cran.utstat.utoronto.ca/")
  10. require(extrafont)
  11. }
  12. font_import(pattern = "Karla")
  13.  
  14. theme_map <- function(...) {
  15. theme_minimal() +
  16. theme(
  17. text = element_text(family = "Karla", color = "#22211d"),
  18. panel.grid.minor = element_blank(),
  19. panel.grid.major = element_blank(),
  20. plot.background = element_rect(fill = "#f5f5f2", color = NA),
  21. panel.background = element_rect(fill = "#f5f5f2", color = NA),
  22. legend.background = element_rect(fill = "#f5f5f2", color = NA),
  23. panel.border = element_blank(), # infuriatingly doesn't work but that's unrelated
  24. aspect.ratio = 9 / 16, # 16:9 aspect ratio
  25. ...
  26. )
  27. }
  28.  
  29. data(iris)
  30.  
  31. p <- ggplot() + geom_point(data=iris, aes(x=iris$Sepal.Length, y=iris$Sepal.Width)) + labs(title="Font Pls") + theme_map()
  32.  
  33. plot(p)
Add Comment
Please, Sign In to add comment