grantmcdermott · GitHub

Introduces a new tinytheme_register function, which allows users to register their own custom theme(s) that can be referenced by name.

pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
# Register a simple custom theme, based on "float" but now with a grid
tinytheme_register("float2", theme = "float", grid = TRUE)
# Use it persistently
tinytheme("float2")
tinyplot(1:5)
tinytheme()
# Or ephemerally
tinyplot(1:5, theme = "float2")
# Optional: unregister the theme
tinytheme_unregister("float2")
# A more elaborate, pirate-themed example
tinytheme_register(
  "pirate",
  theme = "clean",
  family = "HersheyScript",
  bg = "#f5e6c8", fg = "#3b2209",
  cex.lab = 1.5, cex.main = 1.5, cex.sub = 1.2,
  col = "#3b2209", col.axis = "#5c3a1e", col.cap = "#7a5230",
  col.lab = "#3b2209", col.main = "#1a0f04", col.sub = "#7a5230",
  grid = TRUE, grid.col = "#c9a96e", grid.lty = "dotted",
  facet.bg = "#e8d4a8", facet.border = "#5c3a1e",
  pch = 4,
  palette.qualitative = c(
    "#8b0000", "#1a5276", "#196f3d", "#7d6608",
    "#6c3483", "#a04000", "#1b4f72", "#145a32"
  )
)
tinyplot(
  Sepal.Length ~ Petal.Length | Species, iris,
  main = "Avast, me hearties!",
  sub  = "x marks the petal",
  cap  = "Ye Olde Iris Data",
  theme = "pirate"
)
tinytheme_unregister("pirate")

Read the original on github.com ↗