ds_set_theme() sets a theme used by all dynaspec() objects created or shown afterwards in the R session (e.g. in all the code chunks of an R Markdown or Quarto document), as ggplot2::theme_set(). ds_get_theme() returns the current theme.
Arguments
- theme
A theme:
ds_theme()or a preset theme (e.g.ds_theme_dark()).NULLremoves the theme (the defaults of each style are used).
Value
ds_set_theme() returns the previous theme invisibly (so it can be restored); ds_get_theme() returns the current theme (NULL if none was set).
Details
Themes added to a dynaspec() object with + take precedence: ds_theme() changes some settings of the global theme, while preset themes (e.g. + ds_theme_paper()) are complete themes that replace it.
Examples
data(scythebill)
old <- ds_set_theme(ds_theme_dark(cex.lab = 1.3))
# uses the dark theme
x <- dynaspec(scythebill, flim = c(1.5, 5.5)) +
ds_spectrogram(wl = 200, collevels = seq(-50, 0, 1)) + ds_oscillogram()
# dark theme with other axis titles
x <- x + ds_theme(xlab = "Time of the song (s)")
# restore the previous theme
ds_set_theme(old)