Created
June 1, 2021 13:49
-
-
Save KaiAragaki/ea1d1047c9f4d4ac55bf9b48d88e54c8 to your computer and use it in GitHub Desktop.
Tufte-ify your plots with ease!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(showtext) | |
showtext_auto() | |
if(Sys.info()[["sysname"]] == "Windows") { | |
font_add("GillSans", "GIL_____.TTF") | |
} else if(Sys.info()[["sysname"]] == "Darwin") { | |
font_add("GillSans", "GillSans.ttc") | |
} | |
theme_tufte <- function(font_size = 30) { | |
theme( | |
panel.grid = element_blank(), | |
panel.background = element_rect(fill = "#FFFFF8", color = "#CCCCCC"), | |
plot.background = element_rect(fill = "#FFFFF8"), | |
strip.background = element_rect(fill = "#BBBBB0"), | |
legend.background = element_rect(fill = "#FFFFF8"), | |
legend.position = "top", | |
legend.key = element_blank(), | |
text = element_text(family = "GillSans", size = font_size) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment