Skip to contents

A spare, Tufte-inspired look. An old-style serif on a warm white ground, italic column labels, and a single hairline under them. There are no vertical rules, no rules between rows, and no fills. A faint hairline closes the body.

Usage

gt_theme_tufte(
  gt_object,
  accent = "#111111",
  density = c("comfortable", "compact", "social"),
  ...
)

Arguments

gt_object

A gt table object to modify.

accent

Character. A hex color for the header hairline and the row-group labels. Defaults to "#111111", near-black. A muted red or rust gives the Tufte marginal accent.

density

Character. The type and padding scale. One of "comfortable", "compact", or "social". See Density. Defaults to "comfortable".

...

Additional arguments passed to gt::tab_options, applied last so they override anything the theme sets.

Value

Returns a modified gt table with the theme applied.

Details

accent recolors the header hairline and the row-group labels.

Density

density sets the type and padding scale together. "comfortable" uses a 14px body with roomy rows, "compact" a 12px body with tight rows, and "social" a 17px body with generous rows and a larger title, at the scale gt_save_crop() and gt_social_crop() export at.

Figures

Preview of the tufte theme

See also

gt_theme_booktabs() for a firmer, academic relative.

Examples

library(gt)

nfc_north <- subset(
  sdv_example_standings, division == "NFC North",
  c(team_name, wins:points_against)
)
gt(nfc_north) |> gt_theme_tufte()
team_name wins losses ties win_pct points_for points_against
Chicago Bears 11 6 0 0.647 441 415
Green Bay Packers 9 7 1 0.559 391 360
Minnesota Vikings 9 8 0 0.529 344 333
Detroit Lions 9 8 0 0.529 481 413
# a muted rust accent on the hairline atlantic <- subset( sdv_example_standings, division == "Atlantic", c(team_name, wins, losses, win_pct:points_against) ) gt(atlantic) |> gt_theme_tufte(accent = "#7B3F2B")
team_name wins losses win_pct points_for points_against
Boston Celtics 56 26 0.683 9418 8787
New York Knicks 53 29 0.646 9549 9030
Toronto Raptors 46 36 0.561 9400 9168
Philadelphia 76ers 45 37 0.549 9502 9517
Brooklyn Nets 20 62 0.244 8686 9505