Skip to content

Commit d7b4767

Browse files
committed
move examples to @examples, remove geom_sf() example #2136
1 parent e8aa30c commit d7b4767

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

R/plot.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@
4242
#'
4343
#' parameter \code{at} can be set to specify where labels are placed along the key; see examples.
4444
#'
45-
#' The features are plotted in the same order as they order in the sf object. If a different plotting order is wanted
46-
#' (for example to plot smaller polygons on top of larger polygons if they are overlapping), this can be achieved
47-
#' by reordering the sf-object, either permanently (x = x[order(st_area(x), decreasing = TRUE),]) or on-the-fly with dplyr,
48-
#' such as: x %>% arrange(desc(st_area(x))) |> ggplot(aes(fill = column_name)) + geom_sf() .
49-
#'
45+
#' The features are plotted in the order as they apppear in the sf object. See examples for when a different plotting order is wanted.
5046
#'
5147
#' @examples
5248
#' nc = st_read(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE)
@@ -68,6 +64,11 @@
6864
#' layout(matrix(1:2, ncol = 2), widths = c(1, lcm(2)))
6965
#' plot(1)
7066
#' .image_scale(1:10, col = sf.colors(9), key.length = lcm(8), key.pos = 4, at = 1:10)
67+
#' # manipulate plotting order, plot largest polygons first:
68+
#' p = st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))))
69+
#' x = st_sf(a=1:4, st_sfc(p, p * 2, p * 3, p * 4)) # plot(x, col=2:5) only shows the largest polygon!
70+
#' plot(x[order(st_area(x), decreasing = TRUE),], col = 2:5) # plot largest polygons first
71+
#'
7172
#' @export
7273
plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty",
7374
max.plot = if(is.null(n <- getOption("sf_max.plot"))) 9 else n,

man/plot.Rd

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

0 commit comments

Comments
 (0)