@@ -314,7 +314,7 @@ gg2list <- function(p, width = NULL, height = NULL,
314
314
})
315
315
316
316
# Transform all scales
317
- data <- lapply(data , ggfun( " scales_transform_df" ) , scales = scales )
317
+ data <- lapply(data , scales_transform_df , scales = scales )
318
318
319
319
# Map and train positions so that statistics have access to ranges
320
320
# and all positions are numeric
@@ -368,7 +368,7 @@ gg2list <- function(p, width = NULL, height = NULL,
368
368
data <- by_layer(function (l , d ) l $ map_statistic(d , plot ))
369
369
370
370
# Make sure missing (but required) aesthetics are added
371
- ggfun( " scales_add_missing" ) (plot , c(" x" , " y" ), plot $ plot_env )
371
+ scales_add_missing(plot , c(" x" , " y" ))
372
372
373
373
# Reparameterise geoms from (e.g.) y and width to ymin and ymax
374
374
data <- by_layer(function (l , d ) l $ compute_geom_1(d ))
@@ -401,7 +401,7 @@ gg2list <- function(p, width = NULL, height = NULL,
401
401
# Train and map non-position scales
402
402
npscales <- scales $ non_position_scales()
403
403
if (npscales $ n() > 0 ) {
404
- lapply(data , ggfun( " scales_train_df" ) , scales = npscales )
404
+ lapply(data , scales_train_df , scales = npscales )
405
405
# this for loop is unique to plotly -- it saves the "domain"
406
406
# of each non-positional scale for display in tooltips
407
407
for (sc in npscales $ scales ) {
@@ -413,7 +413,7 @@ gg2list <- function(p, width = NULL, height = NULL,
413
413
d
414
414
})
415
415
}
416
- data <- lapply(data , ggfun( " scales_map_df" ) , scales = npscales )
416
+ data <- lapply(data , scales_map_df , scales = npscales )
417
417
}
418
418
419
419
# Fill in defaults etc.
@@ -1459,3 +1459,36 @@ getAesMap <- function(plot, layer) {
1459
1459
layer $ mapping
1460
1460
}
1461
1461
}
1462
+
1463
+ # Handle compatibility for changes in ggplot2 >v3.4.2 (#5144)
1464
+ scales_transform_df <- function (scales , df ) {
1465
+ if (is.function(scales $ transform_df )) {
1466
+ scales $ transform_df(df )
1467
+ } else {
1468
+ ggfun(" scales_transform_df" )(df , scales = scales )
1469
+ }
1470
+ }
1471
+
1472
+ scales_train_df <- function (scales , df ) {
1473
+ if (is.function(scales $ train_df )) {
1474
+ scales $ train_df(df )
1475
+ } else {
1476
+ ggfun(" scales_train_df" )(df , scales = scales )
1477
+ }
1478
+ }
1479
+
1480
+ scales_map_df <- function (scales , df ) {
1481
+ if (is.function(scales $ map_df )) {
1482
+ scales $ map_df(df )
1483
+ } else {
1484
+ ggfun(" scales_map_df" )(df , scales = scales )
1485
+ }
1486
+ }
1487
+
1488
+ scales_add_missing <- function (plot , aesthetics ) {
1489
+ if (length(plot $ scales $ add_missing )) {
1490
+ plot $ scales $ add_missing(c(" x" , " y" ), plot $ plot_env )
1491
+ } else {
1492
+ ggfun(" scales_add_missing" )(plot , aesthetics , plot $ plot_env )
1493
+ }
1494
+ }
0 commit comments