Skip to content

Commit f823679

Browse files
committed
fix guide legends for ggplot2 development version
1 parent ab39bd2 commit f823679

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Diff for: R/layout-circle-build.R

+16-2
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,23 @@ circle_build <- function(circle, schemes = NULL, theme = NULL) {
173173
# build legends
174174
if (packageVersion("ggplot2") > "3.5.1") {
175175
# ggplot2 development version > 3.5.1
176-
guides[[i]] <- plot$guides$assemble(plot_theme)
176+
guide_list <- plot$guides$assemble(plot_theme)
177+
if (!inherits(guide_list, "zeroGrob")) {
178+
guides[[i]] <- lapply(guide_list, function(guide_box) {
179+
if (!inherits(guide_box, "zeroGrob")) {
180+
.subset(
181+
.subset2(guide_box, "grobs"),
182+
grepl(
183+
"guides",
184+
.subset2(.subset2(guide_box, "layout"), "name")
185+
)
186+
)
187+
}
188+
})
189+
}
177190
} else {
178191
default_position <- plot_theme$legend.position %||% "right"
179-
if (length(default_position) == 2) {
192+
if (length(default_position) == 2L) {
180193
default_position <- "inside"
181194
}
182195
if (!identical(default_position, "none")) {
@@ -188,6 +201,7 @@ circle_build <- function(circle, schemes = NULL, theme = NULL) {
188201
"legend.key.height",
189202
plot_theme
190203
)
204+
# A list of list
191205
guides[[i]] <- plot$guides$draw(
192206
plot_theme,
193207
default_position,

0 commit comments

Comments
 (0)