Skip to content

Commit 29a5725

Browse files
authored
Merge pull request #2136 from jskoien/main
Describing plotting order for polygons
2 parents 7671d6c + 9d27e7f commit 29a5725

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

R/plot.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
#' When setting \code{reset} to \code{FALSE}, the original device parameters are lost, and the device must be reset using \code{dev.off()} in order to reset it.
4242
#'
4343
#' parameter \code{at} can be set to specify where labels are placed along the key; see examples.
44+
#'
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+
#'
4450
#'
4551
#' @examples
4652
#' nc = st_read(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE)

0 commit comments

Comments
 (0)