Skip to content

Commit e75c6d6

Browse files
committed
inline update_guides()
1 parent db6feb8 commit e75c6d6

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

R/guides-.R

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,6 @@ guides <- function(...) {
109109
NULL
110110
}
111111

112-
update_guides <- function(p, guides) {
113-
p <- plot_clone(p)
114-
if (inherits(p$guides, "Guides")) {
115-
old <- p$guides
116-
new <- ggproto(NULL, old)
117-
new$add(guides)
118-
p$guides <- new
119-
} else {
120-
p$guides <- guides
121-
}
122-
p
123-
}
124-
125112
# Class -------------------------------------------------------------------
126113

127114
# Guides object encapsulates multiple guides and their state.

R/plot-construction.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,16 @@ ggplot_add.labels <- function(object, plot, object_name) {
126126
}
127127
#' @export
128128
ggplot_add.Guides <- function(object, plot, object_name) {
129-
update_guides(plot, object)
129+
if (inherits(plot$guides, "Guides")) {
130+
# We clone the guides object to prevent modify-in-place of guides
131+
old <- plot$guides
132+
new <- ggproto(NULL, old)
133+
new$add(object)
134+
plot$guides <- new
135+
} else {
136+
plot$guides <- object
137+
}
138+
plot
130139
}
131140
#' @export
132141
ggplot_add.uneval <- function(object, plot, object_name) {

0 commit comments

Comments
 (0)