Skip to content

Commit 6a5dbd0

Browse files
committed
rebase, fix documentation
1 parent fa19ded commit 6a5dbd0

File tree

2 files changed

+45
-49
lines changed

2 files changed

+45
-49
lines changed

R/sf.R

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,6 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
493493
}
494494
graticule$degree_label[graticule$type == "N"] <- y_labels
495495

496-
# remove tick labels not on axes 1 (bottom) and 2 (left)
497-
if (!is.null(graticule$plot12))
498-
graticule$degree_label[!graticule$plot12] <- NA
499-
500496
# Parse labels if requested/needed
501497
has_degree <- grepl("\\bdegree\\b", graticule$degree_label)
502498
needs_parsing <- needs_parsing | (needs_autoparsing & has_degree)
@@ -543,7 +539,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
543539
graticule = graticule,
544540
crs = params$crs,
545541
label_axes = self$label_axes,
546-
label_graticules = self$label_graticules
542+
label_graticule = self$label_graticule
547543
)
548544
},
549545

@@ -587,16 +583,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
587583
id2 <- c(id2, which(graticule$type == panel_params$label_axes$top & graticule$y_end > 0.999))
588584

589585
# labels based on graticule direction
590-
if ("S" %in% panel_params$label_graticules) {
586+
if ("S" %in% panel_params$label_graticule) {
591587
id1 <- c(id1, which(graticule$type == "E" & graticule$y_start > 0.999))
592588
}
593-
if ("N" %in% panel_params$label_graticules) {
589+
if ("N" %in% panel_params$label_graticule) {
594590
id2 <- c(id2, which(graticule$type == "E" & graticule$y_end > 0.999))
595591
}
596-
if ("W" %in% panel_params$label_graticules) {
592+
if ("W" %in% panel_params$label_graticule) {
597593
id1 <- c(id1, which(graticule$type == "N" & graticule$y_start > 0.999))
598594
}
599-
if ("E" %in% panel_params$label_graticules) {
595+
if ("E" %in% panel_params$label_graticule) {
600596
id2 <- c(id2, which(graticule$type == "N" & graticule$y_end > 0.999))
601597
}
602598

@@ -623,16 +619,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
623619
id2 <- c(id2, which(graticule$type == panel_params$label_axes$bottom & graticule$y_end < 0.001))
624620

625621
# labels based on graticule direction
626-
if ("S" %in% panel_params$label_graticules) {
622+
if ("S" %in% panel_params$label_graticule) {
627623
id1 <- c(id1, which(graticule$type == "E" & graticule$y_start < 0.001))
628624
}
629-
if ("N" %in% panel_params$label_graticules) {
625+
if ("N" %in% panel_params$label_graticule) {
630626
id2 <- c(id2, which(graticule$type == "E" & graticule$y_end < 0.001))
631627
}
632-
if ("W" %in% panel_params$label_graticules) {
628+
if ("W" %in% panel_params$label_graticule) {
633629
id1 <- c(id1, which(graticule$type == "N" & graticule$y_start < 0.001))
634630
}
635-
if ("E" %in% panel_params$label_graticules) {
631+
if ("E" %in% panel_params$label_graticule) {
636632
id2 <- c(id2, which(graticule$type == "N" & graticule$y_end < 0.001))
637633
}
638634

@@ -665,16 +661,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
665661
id2 <- c(id2, which(graticule$type == panel_params$label_axes$right & graticule$x_start > 0.999))
666662

667663
# labels based on graticule direction
668-
if ("N" %in% panel_params$label_graticules) {
664+
if ("N" %in% panel_params$label_graticule) {
669665
id1 <- c(id1, which(graticule$type == "E" & graticule$x_end > 0.999))
670666
}
671-
if ("S" %in% panel_params$label_graticules) {
667+
if ("S" %in% panel_params$label_graticule) {
672668
id2 <- c(id2, which(graticule$type == "E" & graticule$x_start > 0.999))
673669
}
674-
if ("E" %in% panel_params$label_graticules) {
670+
if ("E" %in% panel_params$label_graticule) {
675671
id1 <- c(id1, which(graticule$type == "N" & graticule$x_end > 0.999))
676672
}
677-
if ("W" %in% panel_params$label_graticules) {
673+
if ("W" %in% panel_params$label_graticule) {
678674
id2 <- c(id2, which(graticule$type == "N" & graticule$x_start > 0.999))
679675
}
680676

@@ -701,16 +697,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
701697
id2 <- c(id2, which(graticule$type == panel_params$label_axes$left & graticule$x_start < 0.001))
702698

703699
# labels based on graticule direction
704-
if ("N" %in% panel_params$label_graticules) {
700+
if ("N" %in% panel_params$label_graticule) {
705701
id1 <- c(id1, which(graticule$type == "E" & graticule$x_end < 0.001))
706702
}
707-
if ("S" %in% panel_params$label_graticules) {
703+
if ("S" %in% panel_params$label_graticule) {
708704
id2 <- c(id2, which(graticule$type == "E" & graticule$x_start < 0.001))
709705
}
710-
if ("E" %in% panel_params$label_graticules) {
706+
if ("E" %in% panel_params$label_graticule) {
711707
id1 <- c(id1, which(graticule$type == "N" & graticule$x_end < 0.001))
712708
}
713-
if ("W" %in% panel_params$label_graticules) {
709+
if ("W" %in% panel_params$label_graticule) {
714710
id2 <- c(id2, which(graticule$type == "N" & graticule$x_start < 0.001))
715711
}
716712

@@ -754,23 +750,23 @@ sf_rescale01_x <- function(x, range) {
754750
#' If not specified, will use the CRS defined in the first layer.
755751
#' @param datum CRS that provides datum to use when generating graticules
756752
#' @param label_axes Character vector or named list of character values
757-
#' specifying which graticules (meridians or parallels) should be labeled on
753+
#' specifying which graticule lines (meridians or parallels) should be labeled on
758754
#' which side of the plot. Meridians are indicated by `"E"` (for East) and
759755
#' parallels by `"N"` (for North). Default is `"--EN"`, which specifies
760756
#' (clockwise from the top) no labels on the top, none on the right, meridians
761-
#' on the bottom, and paralleles on the left. Alternatively, this setting could have been
757+
#' on the bottom, and parallels on the left. Alternatively, this setting could have been
762758
#' specified with `list(left = "N", bottom = "E")`.
763759
#'
764-
#' This parameter can be used alone or in combination with `label_graticules`.
765-
#' @param label_graticules Character vector indicating which graticules should be labeled
760+
#' This parameter can be used alone or in combination with `label_graticule`.
761+
#' @param label_graticule Character vector indicating which graticule lines should be labeled
766762
#' where. Meridians run north-south, and the letters `"N"` and `"S"` indicate that
767763
#' they should be labeled on their north or south end points, respectively.
768764
#' Parallels run east-west, and the letters `"E"` and `"W"` indicate that they
769765
#' should be labeled on their east or west end points, respectively. Thus,
770-
#' `label_graticules = "SW"` would label meridians at their south end and parallels at
771-
#' their west end, whereas `label_graticules = "EW"` would label parallels at both
766+
#' `label_graticule = "SW"` would label meridians at their south end and parallels at
767+
#' their west end, whereas `label_graticule = "EW"` would label parallels at both
772768
#' ends and meridians not at all. Because meridians and parallels can in general
773-
#' intersect with any side of the plot panel, for any choice of `label_graticules` labels
769+
#' intersect with any side of the plot panel, for any choice of `label_graticule` labels
774770
#' are not guaranteed to reside on only one particular side of the plot panel.
775771
#'
776772
#' This parameter can be used alone or in combination with `label_axes`.
@@ -781,47 +777,47 @@ sf_rescale01_x <- function(x, range) {
781777
#' @rdname ggsf
782778
coord_sf <- function(xlim = NULL, ylim = NULL, expand = TRUE,
783779
crs = NULL, datum = sf::st_crs(4326),
784-
label_graticules = waiver(),
780+
label_graticule = waiver(),
785781
label_axes = waiver(),
786782
ndiscr = 100, default = FALSE) {
787783

788-
if (is.waive(label_graticules) && is.waive(label_axes)) {
789-
# if both `label_graticules` and `label_axes` are set to waive then we
784+
if (is.waive(label_graticule) && is.waive(label_axes)) {
785+
# if both `label_graticule` and `label_axes` are set to waive then we
790786
# use the default of labels on the left and at the bottom
791-
label_graticules <- ""
787+
label_graticule <- ""
792788
label_axes <- "--EN"
793789
} else {
794790
# if at least one is set we ignore the other
795-
label_graticules <- label_graticules %|W|% ""
791+
label_graticule <- label_graticule %|W|% ""
796792
label_axes <- label_axes %|W|% ""
797793
}
798794

799795
if (is.character(label_axes)) {
800796
label_axes <- parse_axes_labeling(label_axes)
801797
} else if (!is.list(label_axes)) {
802-
warning(
803-
"Panel labeling format not recognized. Proceeding with default settings.",
798+
stop(
799+
"Panel labeling format not recognized.",
804800
call. = FALSE
805801
)
806802
label_axes <- list(left = "N", bottom = "E")
807803
}
808804

809-
if (is.character(label_graticules)) {
810-
label_graticules <- unlist(strsplit(label_graticules, ""))
805+
if (is.character(label_graticule)) {
806+
label_graticule <- unlist(strsplit(label_graticule, ""))
811807
} else {
812-
warning(
813-
"Graticule labeling format not recognized. Proceeding with default settings.",
808+
stop(
809+
"Graticule labeling format not recognized.",
814810
call. = FALSE
815811
)
816-
label_graticules <- ""
812+
label_graticule <- ""
817813
}
818814

819815
ggproto(NULL, CoordSf,
820816
limits = list(x = xlim, y = ylim),
821817
datum = datum,
822818
crs = crs,
823819
label_axes = label_axes,
824-
label_graticules = label_graticules,
820+
label_graticule = label_graticule,
825821
ndiscr = ndiscr,
826822
expand = expand,
827823
default = default

man/ggsf.Rd

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

0 commit comments

Comments
 (0)