Skip to content

Commit e361782

Browse files
committed
remove option for explicit parsing, not needed
1 parent 3605a94 commit e361782

File tree

3 files changed

+11
-62
lines changed

3 files changed

+11
-62
lines changed

R/sf.R

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,6 @@ scale_type.sfc <- function(x) "identity"
383383
#' @usage NULL
384384
#' @format NULL
385385
CoordSf <- ggproto("CoordSf", CoordCartesian,
386-
# parameters that control the parsing of labels plotted in the
387-
# N or E directions
388-
parse_N_labels = FALSE,
389-
parse_E_labels = FALSE,
390386

391387
# Find the first CRS if not already supplied
392388
setup_params = function(self, data) {
@@ -462,7 +458,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
462458
}
463459

464460
if (is.character(x_labels)) {
465-
needs_parsing[graticule$type == "E"] <- self$parse_E_labels
461+
needs_parsing[graticule$type == "E"] <- FALSE
466462
} else {
467463
# all labels need to be temporarily stored as character vectors
468464
x_labels <- as.character(x_labels)
@@ -490,7 +486,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
490486
}
491487

492488
if (is.character(y_labels)) {
493-
needs_parsing[graticule$type == "N"] <- self$parse_N_labels
489+
needs_parsing[graticule$type == "N"] <- FALSE
494490
} else {
495491
# all labels need to be temporarily stored as character vectors
496492
y_labels <- as.character(y_labels)
@@ -636,29 +632,18 @@ sf_rescale01_x <- function(x, range) {
636632
#' @param datum CRS that provides datum to use when generating graticules
637633
#' @param ndiscr number of segments to use for discretising graticule lines;
638634
#' try increasing this when graticules look unexpected
639-
#' @param parse_N_labels If `TRUE`, labels indicating latitude (the degree to which
640-
#' we are north or south) are parsed into R expressions before plotting. These
641-
#' correspond to y-axis tick labels in a simple latitude-longitude plot.
642-
#' Default is `FALSE`.
643-
#' @param parse_E_labels If `TRUE`, labels indicating longitude (the degree to which
644-
#' we are east or west) are parsed into R expressions before plotting. These
645-
#' correspond to x-axis tick labels in a simple latitude-longitude plot.
646-
#' Default is `FALSE`.
647635
#' @inheritParams coord_cartesian
648636
#' @export
649637
#' @rdname ggsf
650638
coord_sf <- function(xlim = NULL, ylim = NULL, expand = TRUE,
651639
crs = NULL, datum = sf::st_crs(4326), ndiscr = 100,
652-
parse_N_labels = FALSE, parse_E_labels = FALSE,
653640
default = FALSE) {
654641
ggproto(NULL, CoordSf,
655642
limits = list(x = xlim, y = ylim),
656643
datum = datum,
657644
crs = crs,
658645
ndiscr = ndiscr,
659646
expand = expand,
660-
parse_N_labels = parse_N_labels,
661-
parse_E_labels = parse_E_labels,
662647
default = default
663648
)
664649
}

man/ggsf.Rd

Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-coord_sf.R

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,52 +84,27 @@ test_that("axis labels can be set manually", {
8484
parsed
8585
)
8686

87-
# parsing via coord_sf()
87+
# reverse x and y from previous test
8888
b <- ggplot_build(
8989
plot +
90-
scale_x_continuous(
91-
breaks = c(1000, 2000, 3000),
92-
labels = c("10^3", "2 %*% 10^3", "3 %*% 10^3")
93-
) +
9490
scale_y_continuous(
95-
breaks = c(1000, 1500, 2000),
96-
labels = c("10^3", "1.5 %*% 10^3", "2 %*% 10^3")
97-
) +
98-
coord_sf(parse_E_labels = TRUE, parse_N_labels = FALSE)
99-
)
100-
graticule <- b$layout$panel_params[[1]]$graticule
101-
parsed <- vector("list", 3)
102-
parsed[1:3] <- parse(text = c("10^3", "2 %*% 10^3", "3 %*% 10^3"))
103-
expect_identical(
104-
graticule[graticule$type == "E", ]$degree_label,
105-
parsed
106-
)
107-
expect_identical(
108-
graticule[graticule$type == "N", ]$degree_label,
109-
as.list(c("10^3", "1.5 %*% 10^3", "2 %*% 10^3"))
110-
)
111-
112-
b <- ggplot_build(
113-
plot +
114-
scale_x_continuous(
11591
breaks = c(1000, 2000, 3000),
116-
labels = c("10^3", "2 %*% 10^3", "3 %*% 10^3")
92+
labels = c("A", "B", "C")
11793
) +
118-
scale_y_continuous(
94+
scale_x_continuous(
11995
breaks = c(1000, 1500, 2000),
120-
labels = c("10^3", "1.5 %*% 10^3", "2 %*% 10^3")
121-
) +
122-
coord_sf(parse_E_labels = FALSE, parse_N_labels = TRUE)
96+
labels = parse(text = c("10^3", "1.5 %*% 10^3", "2 %*% 10^3"))
97+
)
12398
)
12499
graticule <- b$layout$panel_params[[1]]$graticule
125100
expect_identical(
126-
graticule[graticule$type == "E", ]$degree_label,
127-
as.list(c("10^3", "2 %*% 10^3", "3 %*% 10^3"))
101+
graticule[graticule$type == "N", ]$degree_label,
102+
as.list(c("A", "B", "C"))
128103
)
129104
parsed <- vector("list", 3)
130105
parsed[1:3] <- parse(text = c("10^3", "1.5 %*% 10^3", "2 %*% 10^3"))
131106
expect_identical(
132-
graticule[graticule$type == "N", ]$degree_label,
107+
graticule[graticule$type == "E", ]$degree_label,
133108
parsed
134109
)
135110

0 commit comments

Comments
 (0)