Skip to content

Commit 19efebc

Browse files
committed
avoid calling sf functions unless geom_sf() is used
1 parent 4837e7d commit 19efebc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

R/ggplotly.R

+4-2
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ gg2list <- function(p, width = NULL, height = NULL,
716716
axisObj$scaleanchor <- anchor
717717
ratio <- p$coordinates$ratio %||% 1
718718
# a la CoordSf$aspect
719-
if (isTRUE(sf::st_is_longlat(rng$crs))) {
720-
ratio <- cos(mean(rng$y_range) * pi/180)
719+
if (inherits(p$coordinates, "CoordSf")) {
720+
if (isTRUE(sf::st_is_longlat(rng$crs))) {
721+
ratio <- cos(mean(rng$y_range) * pi/180)
722+
}
721723
}
722724
axisObj$scaleratio <- if (xy == "y") ratio else 1 / ratio
723725
}

0 commit comments

Comments
 (0)