diff --git a/R/coord-sf.R b/R/coord-sf.R index 81207f2ce1..0fe34293de 100644 --- a/R/coord-sf.R +++ b/R/coord-sf.R @@ -255,19 +255,24 @@ CoordSf <- ggproto("CoordSf", CoordCartesian, graticule$y_start <- sf_rescale01_x(graticule$y_start, y_range) graticule$y_end <- sf_rescale01_x(graticule$y_end, y_range) - list( + list2( x_range = x_range, y_range = y_range, graticule = graticule, crs = params$crs, default_crs = params$default_crs, - viewscales = viewscales + !!!viewscales ) }, - setup_panel_guides = function(self, panel_params, guides, params = list()) { - params <- Coord$setup_panel_guides(panel_params$viewscales, guides, params) - c(params, panel_params) + train_panel_guides = function(self, panel_params, layers, params = list()) { + # The guide positions are already in the target CRS, so we mask the default + # CRS to prevent a double transformation. + panel_params$guides <- ggproto_parent(Coord, self)$train_panel_guides( + vec_assign(panel_params, "default_crs", panel_params["crs"]), + layers, params + )$guides + panel_params }, backtransform_range = function(self, panel_params) { diff --git a/R/guide-axis.R b/R/guide-axis.R index eac32b2b98..581370b49d 100644 --- a/R/guide-axis.R +++ b/R/guide-axis.R @@ -135,11 +135,6 @@ GuideAxis <- ggproto( return(params) } - if (inherits(coord, "CoordSf")) { - # Positions already given in target crs - panel_params$default_crs <- panel_params$crs - } - aesthetics <- names(key)[!grepl("^\\.", names(key))] if (!all(c("x", "y") %in% aesthetics)) { other_aesthetic <- setdiff(c("x", "y"), aesthetics)