@@ -493,10 +493,6 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
493
493
}
494
494
graticule $ degree_label [graticule $ type == " N" ] <- y_labels
495
495
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
-
500
496
# Parse labels if requested/needed
501
497
has_degree <- grepl(" \\ bdegree\\ b" , graticule $ degree_label )
502
498
needs_parsing <- needs_parsing | (needs_autoparsing & has_degree )
@@ -543,7 +539,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
543
539
graticule = graticule ,
544
540
crs = params $ crs ,
545
541
label_axes = self $ label_axes ,
546
- label_graticules = self $ label_graticules
542
+ label_graticule = self $ label_graticule
547
543
)
548
544
},
549
545
@@ -587,16 +583,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
587
583
id2 <- c(id2 , which(graticule $ type == panel_params $ label_axes $ top & graticule $ y_end > 0.999 ))
588
584
589
585
# labels based on graticule direction
590
- if (" S" %in% panel_params $ label_graticules ) {
586
+ if (" S" %in% panel_params $ label_graticule ) {
591
587
id1 <- c(id1 , which(graticule $ type == " E" & graticule $ y_start > 0.999 ))
592
588
}
593
- if (" N" %in% panel_params $ label_graticules ) {
589
+ if (" N" %in% panel_params $ label_graticule ) {
594
590
id2 <- c(id2 , which(graticule $ type == " E" & graticule $ y_end > 0.999 ))
595
591
}
596
- if (" W" %in% panel_params $ label_graticules ) {
592
+ if (" W" %in% panel_params $ label_graticule ) {
597
593
id1 <- c(id1 , which(graticule $ type == " N" & graticule $ y_start > 0.999 ))
598
594
}
599
- if (" E" %in% panel_params $ label_graticules ) {
595
+ if (" E" %in% panel_params $ label_graticule ) {
600
596
id2 <- c(id2 , which(graticule $ type == " N" & graticule $ y_end > 0.999 ))
601
597
}
602
598
@@ -623,16 +619,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
623
619
id2 <- c(id2 , which(graticule $ type == panel_params $ label_axes $ bottom & graticule $ y_end < 0.001 ))
624
620
625
621
# labels based on graticule direction
626
- if (" S" %in% panel_params $ label_graticules ) {
622
+ if (" S" %in% panel_params $ label_graticule ) {
627
623
id1 <- c(id1 , which(graticule $ type == " E" & graticule $ y_start < 0.001 ))
628
624
}
629
- if (" N" %in% panel_params $ label_graticules ) {
625
+ if (" N" %in% panel_params $ label_graticule ) {
630
626
id2 <- c(id2 , which(graticule $ type == " E" & graticule $ y_end < 0.001 ))
631
627
}
632
- if (" W" %in% panel_params $ label_graticules ) {
628
+ if (" W" %in% panel_params $ label_graticule ) {
633
629
id1 <- c(id1 , which(graticule $ type == " N" & graticule $ y_start < 0.001 ))
634
630
}
635
- if (" E" %in% panel_params $ label_graticules ) {
631
+ if (" E" %in% panel_params $ label_graticule ) {
636
632
id2 <- c(id2 , which(graticule $ type == " N" & graticule $ y_end < 0.001 ))
637
633
}
638
634
@@ -665,16 +661,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
665
661
id2 <- c(id2 , which(graticule $ type == panel_params $ label_axes $ right & graticule $ x_start > 0.999 ))
666
662
667
663
# labels based on graticule direction
668
- if (" N" %in% panel_params $ label_graticules ) {
664
+ if (" N" %in% panel_params $ label_graticule ) {
669
665
id1 <- c(id1 , which(graticule $ type == " E" & graticule $ x_end > 0.999 ))
670
666
}
671
- if (" S" %in% panel_params $ label_graticules ) {
667
+ if (" S" %in% panel_params $ label_graticule ) {
672
668
id2 <- c(id2 , which(graticule $ type == " E" & graticule $ x_start > 0.999 ))
673
669
}
674
- if (" E" %in% panel_params $ label_graticules ) {
670
+ if (" E" %in% panel_params $ label_graticule ) {
675
671
id1 <- c(id1 , which(graticule $ type == " N" & graticule $ x_end > 0.999 ))
676
672
}
677
- if (" W" %in% panel_params $ label_graticules ) {
673
+ if (" W" %in% panel_params $ label_graticule ) {
678
674
id2 <- c(id2 , which(graticule $ type == " N" & graticule $ x_start > 0.999 ))
679
675
}
680
676
@@ -701,16 +697,16 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
701
697
id2 <- c(id2 , which(graticule $ type == panel_params $ label_axes $ left & graticule $ x_start < 0.001 ))
702
698
703
699
# labels based on graticule direction
704
- if (" N" %in% panel_params $ label_graticules ) {
700
+ if (" N" %in% panel_params $ label_graticule ) {
705
701
id1 <- c(id1 , which(graticule $ type == " E" & graticule $ x_end < 0.001 ))
706
702
}
707
- if (" S" %in% panel_params $ label_graticules ) {
703
+ if (" S" %in% panel_params $ label_graticule ) {
708
704
id2 <- c(id2 , which(graticule $ type == " E" & graticule $ x_start < 0.001 ))
709
705
}
710
- if (" E" %in% panel_params $ label_graticules ) {
706
+ if (" E" %in% panel_params $ label_graticule ) {
711
707
id1 <- c(id1 , which(graticule $ type == " N" & graticule $ x_end < 0.001 ))
712
708
}
713
- if (" W" %in% panel_params $ label_graticules ) {
709
+ if (" W" %in% panel_params $ label_graticule ) {
714
710
id2 <- c(id2 , which(graticule $ type == " N" & graticule $ x_start < 0.001 ))
715
711
}
716
712
@@ -754,23 +750,23 @@ sf_rescale01_x <- function(x, range) {
754
750
# ' If not specified, will use the CRS defined in the first layer.
755
751
# ' @param datum CRS that provides datum to use when generating graticules
756
752
# ' @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
758
754
# ' which side of the plot. Meridians are indicated by `"E"` (for East) and
759
755
# ' parallels by `"N"` (for North). Default is `"--EN"`, which specifies
760
756
# ' (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
762
758
# ' specified with `list(left = "N", bottom = "E")`.
763
759
# '
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
766
762
# ' where. Meridians run north-south, and the letters `"N"` and `"S"` indicate that
767
763
# ' they should be labeled on their north or south end points, respectively.
768
764
# ' Parallels run east-west, and the letters `"E"` and `"W"` indicate that they
769
765
# ' 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
772
768
# ' 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
774
770
# ' are not guaranteed to reside on only one particular side of the plot panel.
775
771
# '
776
772
# ' This parameter can be used alone or in combination with `label_axes`.
@@ -781,47 +777,47 @@ sf_rescale01_x <- function(x, range) {
781
777
# ' @rdname ggsf
782
778
coord_sf <- function (xlim = NULL , ylim = NULL , expand = TRUE ,
783
779
crs = NULL , datum = sf :: st_crs(4326 ),
784
- label_graticules = waiver(),
780
+ label_graticule = waiver(),
785
781
label_axes = waiver(),
786
782
ndiscr = 100 , default = FALSE ) {
787
783
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
790
786
# use the default of labels on the left and at the bottom
791
- label_graticules <- " "
787
+ label_graticule <- " "
792
788
label_axes <- " --EN"
793
789
} else {
794
790
# if at least one is set we ignore the other
795
- label_graticules <- label_graticules %| W | % " "
791
+ label_graticule <- label_graticule %| W | % " "
796
792
label_axes <- label_axes %| W | % " "
797
793
}
798
794
799
795
if (is.character(label_axes )) {
800
796
label_axes <- parse_axes_labeling(label_axes )
801
797
} 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." ,
804
800
call. = FALSE
805
801
)
806
802
label_axes <- list (left = " N" , bottom = " E" )
807
803
}
808
804
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 , " " ))
811
807
} else {
812
- warning (
813
- " Graticule labeling format not recognized. Proceeding with default settings. " ,
808
+ stop (
809
+ " Graticule labeling format not recognized." ,
814
810
call. = FALSE
815
811
)
816
- label_graticules <- " "
812
+ label_graticule <- " "
817
813
}
818
814
819
815
ggproto(NULL , CoordSf ,
820
816
limits = list (x = xlim , y = ylim ),
821
817
datum = datum ,
822
818
crs = crs ,
823
819
label_axes = label_axes ,
824
- label_graticules = label_graticules ,
820
+ label_graticule = label_graticule ,
825
821
ndiscr = ndiscr ,
826
822
expand = expand ,
827
823
default = default
0 commit comments