Skip to content

Instantly share code, notes, and snippets.

@KaiAragaki
Created June 1, 2021 13:49
Show Gist options
  • Save KaiAragaki/ea1d1047c9f4d4ac55bf9b48d88e54c8 to your computer and use it in GitHub Desktop.
Save KaiAragaki/ea1d1047c9f4d4ac55bf9b48d88e54c8 to your computer and use it in GitHub Desktop.
Tufte-ify your plots with ease!
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