R/onload.R

Defines functions .onLoad

utils::globalVariables(c(
  "from_theme",
  "ink",
  "paper",
  "colour",
  "fill",
  "borderwidth",
  "bordertype"
))

.onLoad <- function(libname, pkgname) {

  # if 'ggplot2' >= 4.0.0 we update the Geom "definition" to retrieve defaults
  # from the theme, as the geom element is available
  if ("element_geom" %in% getNamespaceExports("ggplot2")) {
    ggplot2::update_geom_defaults(
        GeomSpct,
        ggplot2::aes(colour = ggplot2::from_theme(colour %||% NA),
                     fill = ggplot2::from_theme(fill %||% scales::col_mix(ink, paper, 0.6)),
                     linewidth = ggplot2::from_theme(borderwidth),
                     linetype = ggplot2::from_theme(bordertype),
                     alpha = NA)
        )
    }

}

Try the ggspectra package in your browser

Any scripts or data that you put into this service are public.

ggspectra documentation built on March 18, 2026, 1:06 a.m.