diff --git a/R/ggplotly.R b/R/ggplotly.R index e358bce17a..7922f4e3f3 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -784,7 +784,8 @@ gg2list <- function(p, width = NULL, height = NULL, # the logic here is similar to what p$coordinates$aspect() does, # but the ratio is scaled to the data range by plotly.js fixed_coords <- c("CoordSf", "CoordFixed", "CoordMap", "CoordQuickmap") - if (inherits(p$coordinates, fixed_coords)) { + is_fixed <- isFALSE(p$coordinates$is_free()) + if (inherits(p$coordinates, fixed_coords) || is_fixed) { axisObj$scaleanchor <- anchor ratio <- p$coordinates$ratio %||% 1 axisObj$scaleratio <- if (xy == "y") ratio else 1 / ratio diff --git a/tests/testthat/test-ggplot-labels.R b/tests/testthat/test-ggplot-labels.R index 4a4a8cfb34..69ca3b4e22 100644 --- a/tests/testthat/test-ggplot-labels.R +++ b/tests/testthat/test-ggplot-labels.R @@ -51,6 +51,6 @@ test_that("empty labels work", { p <- ggplot(palmerpenguins::penguins, aes(bill_length_mm, bill_depth_mm, color = species)) + geom_point() + - labs(x = element_blank(), y = element_blank()) + labs(x = NULL, y = NULL) b <- expect_doppelganger_built(p, "labs-element-blank") })