Usage
tinytheme(
theme = c("default", "basic", "dynamic", "clean", "clean2", "bw", "classic", "minimal",
"ipsum", "dark", "ridge", "ridge2", "tufte", "void"),
...
)
Details
Sets a list of graphical parameters using tpar()
Persistent vs. ephemeral themes. Calling tinytheme(“<theme>”) triggers a persistent theme, which will be applied to all subsequent graphics (incl. base plot). To reset the theme to your default settings, call tinytheme() without arguments. Alternatively, invoke the tinyplot(…, theme = <theme>) argument for an ephemeral theme that is automatically reset at the end of the plot call.
# Set a persistent theme
tinytheme("clean")
tinyplot(1:10) # uses "clean"
tinyplot(10:1) # still uses "clean"
tinytheme() # reset to default
# Use an ephemeral theme for a single plot (incl. added components)
tinyplot(1:10, theme = "dark") # uses "dark" ephemerally
tinyplot_add(type = "S") # same plot, so retains theme
tinyplot(10:1) # new plot, so back to default
Custom overrides. To customize a theme’s parameters (e.g., mar, las, etc.), pass them directly as additional args to tinytheme(<theme>, …). Please note that passing overrides through tpar() or par() won’t work, because themes work by installing a persistent hook, which means that an active theme will override any subsequent calls for parameters that the theme controls.
# Do this
tinytheme("clean", mar = c(5, 5, 2, 2))
<some plot>
# Not this (the theme hook will overwrite your changes)
tinytheme("clean")
tpar(mar = c(5, 5, 2, 2))
<some plot>
Spacing primitives. Dynamic themes compute mgp (margin line positions) automatically from two spacing primitives, rather than requiring users to reason about how mar, mgp, and tcl combine:
-
gap.axis: the gap in margin lines between the tick tip and the near edge of the tick label. Default 0.2.
-
gap.lab: the gap in margin lines between the far edge of the tick label and the near edge of the axis title. Default 1.0.
These primitives scale automatically with cex.axis and cex.lab, so the visible spacing between elements remains constant regardless of text size. To adjust spacing, pass them as overrides:
# Tighter spacing between tick labels and axis titles
tinytheme("clean", gap.lab = 0.5)
# More room between ticks and tick labels
tinytheme("clean", gap.axis = 0.5)
If you supply an explicit mgp value, it is used as-is and the primitives are ignored.
Caveats. Known tinytheme limitations include: