From c037c68df3a24aadac3a9f23cd2b3fc0051d4754 Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 26 Dec 2019 11:30:46 -0600 Subject: [PATCH] Respect sf's plot12 graticule attribute when building axis ticks, fixes #1673 --- R/ggplotly.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/ggplotly.R b/R/ggplotly.R index 55c2060bb0..c8d5129705 100644 --- a/R/ggplotly.R +++ b/R/ggplotly.R @@ -612,7 +612,13 @@ gg2list <- function(p, width = NULL, height = NULL, if ("CoordSf" %in% class(p$coordinates)) { # see CoordSf$render_axis_v direction <- if (xy == "x") "E" else "N" - idx <- rng$graticule$type == direction & !is.na(rng$graticule$degree_label) + idx <- rng$graticule$type == direction & + !is.na(rng$graticule$degree_label) & + # Respect the logical 'plot12' column which sf constructs for + # determining which tick labels should be drawn + # https://github.com/r-spatial/sf/blob/b49d37/R/graticule.R#L199 + # https://github.com/r-spatial/sf/blob/52a8351/R/plot.R#L580 + (rng$graticule$plot12 %||% TRUE) tickData <- rng$graticule[idx, ] # TODO: how to convert a language object to unicode character string? rng[[paste0(xy, ".labels")]] <- sub(