Skip to content

Commit d2ce054

Browse files
committed
use update_ggplot() S7 method instead of ggplot_add.scale_params
1 parent 5364760 commit d2ce054

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ S3method(fortify,tbl_df)
4949
S3method(ggplot,"function")
5050
S3method(ggplot,default)
5151
S3method(ggplot_add,default)
52-
S3method(ggplot_add,scale_params)
5352
S3method(grid.draw,absoluteGrob)
5453
S3method(grobHeight,absoluteGrob)
5554
S3method(grobWidth,absoluteGrob)

R/plot-construction.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ S7::method(update_ggplot, list(S7::new_S3_class("by"), class_ggplot)) <-
237237
ggplot_add(unclass(object), plot, object_name)
238238
}
239239

240+
S7::method(update_ggplot, list(scale_params, class_ggplot)) <-
241+
function(object, plot, ...) {
242+
plot$scales$add_params(object@aesthetics, object@params)
243+
plot
244+
}
245+
240246
# TODO: the S3 generic should be phased out once S7 is adopted more widely
241247
# For backward compatibility, ggplot_add still exists but by default it wraps
242248
# `update_ggplot()`
@@ -251,12 +257,6 @@ ggplot_add.default <- function(object, plot, ...) {
251257
update_ggplot(object = object, plot = plot, ...)
252258
}
253259

254-
#' @export
255-
ggplot_add.scale_params <- function(object, plot, object_name) {
256-
plot$scales$add_params(object$aesthetics, object$params)
257-
plot
258-
}
259-
260260
new_layer_names <- function(layer, existing) {
261261

262262
empty <- !nzchar(existing)

0 commit comments

Comments
 (0)