diff --git a/R/grob-null.r b/R/grob-null.r index 5af4c40ca5..06dcb75a6d 100644 --- a/R/grob-null.r +++ b/R/grob-null.r @@ -4,7 +4,9 @@ #' @export zeroGrob <- function() .zeroGrob -.zeroGrob <- grob(cl = "zeroGrob", name = "NULL") +# Will get assigned in .onLoad() +.zeroGrob <- NULL + #' @export #' @method widthDetails zeroGrob widthDetails.zeroGrob <- function(x) unit(0, "cm") diff --git a/R/theme-current.R b/R/theme-current.R index 7bb0f061b1..ac860f9371 100644 --- a/R/theme-current.R +++ b/R/theme-current.R @@ -1,6 +1,6 @@ #' @include theme-defaults.r #' @include theme-elements.r -ggplot_global$theme_current <- theme_gray() +NULL #' Get, set, and modify the active theme #' diff --git a/R/zzz.r b/R/zzz.r index 9e569b2087..3e5843be7b 100644 --- a/R/zzz.r +++ b/R/zzz.r @@ -19,6 +19,10 @@ .onLoad <- function(...) { backport_unit_methods() + .zeroGrob <<- grob(cl = "zeroGrob", name = "NULL") + + ggplot_global$theme_current <- theme_gray() + # To avoid namespace clash with dplyr. # It seems surprising that this hack works if (requireNamespace("dplyr", quietly = TRUE)) {