ggplot2 theme for Tufte minimalist design

482 Views Asked by At

Tufte thinks this design of bar charts has a high data-ink-ratio. Is there a style available implementing this design?

Minimalist bar chart

1

There are 1 best solutions below

0
stefan On

You could go a long way to achieve your desired result by using ggthemes::theme_tufte. However, replicating the style of the chart in your image requires some additional theme adjustments and at least one hack for the axis line (for which I use a geom_line):

library(ggplot2)

dat <- data.frame(
  month = factor(month.abb[1:9], levels = month.abb[1:9]),
  value = seq(.02, .2, length.out = 9)
)

width <- .45
ggplot(dat, aes(month, value)) +
  geom_col(width = width) +
  geom_line(data = data.frame(x = c(1 - width / 2, 9 + width / 2), y = 0), aes(x, y), color = "grey60") +
  scale_y_continuous(breaks = seq(.05, .2, .05), labels = scales::label_percent(), expand = expansion(c(0.005, .05))) +
  labs(x = NULL, y = NULL) +
  ggthemes::theme_tufte(base_family = "sans") +
  theme(
    panel.ontop = TRUE,
    panel.grid.major.y = element_line(color = "white", size = .25),
    axis.ticks.y = element_line(size = .25),
    axis.ticks.x = element_blank(),
    axis.ticks.length.y = unit(10, "pt")
  )