diff --git a/NEWS.md b/NEWS.md index f325bec637..5b65a25614 100644 --- a/NEWS.md +++ b/NEWS.md @@ -268,6 +268,7 @@ aesthetics (@teunbrand, #2800). * Stricter check on `register_theme_elements(element_tree)` (@teunbrand, #6162) * Added `weight` aesthetic for `stat_ellipse()` (@teunbrand, #5272) +* Fixed a bug where the `guide_custom(order)` wasn't working (@teunbrand, #6195) # ggplot2 3.5.1 diff --git a/R/guides-.R b/R/guides-.R index 0e7ca26882..63a17cc430 100644 --- a/R/guides-.R +++ b/R/guides-.R @@ -306,8 +306,9 @@ Guides <- ggproto( return(no_guides) } - guides$guides <- c(guides$guides, custom$guides) - guides$params <- c(guides$params, custom$params) + ord <- order(c(names(guides$guides), names(custom$guides))) + guides$guides <- c(guides$guides, custom$guides)[ord] + guides$params <- c(guides$params, custom$params)[ord] guides },