Skip to content

Commit de3f0ec

Browse files
authored
Compatibility ggplot2 4.0.0 (#74)
1 parent 630d63b commit de3f0ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

R/guide_marquee.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ guide_marquee <- function(
103103
order = 1
104104
) {
105105
check_installed("ggplot2", version = "3.5.0")
106-
if (!(ggplot2::is.theme(theme) || is.null(theme))) {
106+
107+
is_theme <- get0("is_theme", asNamespace("ggplot2"), ifnotfound = ggplot2::is.theme)
108+
if (!(is_theme(theme) || is.null(theme))) {
107109
stop_input_type(theme, "a <theme>")
108110
}
109111
if (!is.null(position)) {
@@ -256,7 +258,12 @@ on_load(on_package_load("ggplot2", {
256258
}))
257259

258260
group_glyphs <- function(self, params, elems) {
259-
n_layers <- length(params$decor) + 1
261+
262+
if ("class_ggplot" %in% getNamespaceExports("ggplot2")) {
263+
n_layers <- 1
264+
} else {
265+
n_layers <- length(params$decor) + 1
266+
}
260267
n_breaks <- params$n_breaks <- nrow(params$key)
261268
size <- convertUnit(unit(elems$title$size, "pt"), "cm", valueOnly = TRUE)
262269

0 commit comments

Comments
 (0)