How to define the order of the rasters shown with `show_landscape()`?
Closed this issue · 3 comments
Hi,
I want to show a set of rasters in a given order with landscapetools::show_landscape()
, but it seems the function always plot the several rasters in alfabetic order, according to their names. Would it be possible to plot using the same sequence of the input list of rasters (regardless of their names), or even to decide which order to use?
Here an example to show that.
library(raster)
library(NLMR)
library(landscapetools)
set.seed(123)
# parameters
param_df <- expand.grid(ncol = 100,
nrow = 100,
resolution = 100,
roughness = c(2, seq(0.9, 0.1, -0.2))) %>%
tibble::as_tibble()
# simulated landscapes
nlm_mpd_seed <- function(user_seed = 123, ...) {
set.seed(user_seed)
NLMR::nlm_mpd(...)
}
# simulate rasters
nlm_list <- param_df %>% purrr::pmap(nlm_mpd_seed, user_seed = 123)
names(nlm_list) <- types <- c("random", paste0("clust", 1:5))
# plot
landscapetools::show_landscape(nlm_list)
I wanted to show the random landscape first, followed by the maps in a gradient of clumpiness. However, because of the name, the random one is moved to the end of the plot.
Session Info
> devtools::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.0.3 (2020-10-10)
os Ubuntu 18.04.6 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz Europe/Oslo
date 2021-12-01
─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
! package * version date lib source
assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.3)
backports 1.4.0 2021-11-23 [1] CRAN (R 4.0.3)
cachem 1.0.6 2021-08-19 [2] CRAN (R 4.0.3)
callr 3.7.0 2021-04-20 [2] CRAN (R 4.0.3)
checkmate 2.0.0 2020-02-06 [2] CRAN (R 4.0.3)
class 7.3-19 2021-05-03 [4] CRAN (R 4.0.3)
classInt 0.4-3 2020-04-07 [2] CRAN (R 4.0.3)
cli 3.1.0 2021-10-27 [1] CRAN (R 4.0.3)
codetools 0.2-18 2020-11-04 [4] CRAN (R 4.0.3)
colorspace 2.0-2 2021-06-24 [2] CRAN (R 4.0.3)
VP crayon 1.4.1 2021-10-29 [2] CRAN (R 4.0.3)
DBI 1.1.1 2021-01-15 [2] CRAN (R 4.0.3)
desc 1.4.0 2021-09-28 [2] CRAN (R 4.0.3)
devtools 2.4.2 2021-06-07 [2] CRAN (R 4.0.3)
digest 0.6.28 2021-09-23 [2] CRAN (R 4.0.3)
dplyr * 1.0.7 2021-06-18 [2] CRAN (R 4.0.3)
e1071 1.7-9 2021-09-16 [2] CRAN (R 4.0.3)
P ellipsis 0.3.2 2021-04-29 [2] CRAN (R 4.0.3)
evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.3)
fansi 0.5.0 2021-05-25 [2] CRAN (R 4.0.3)
farver 2.1.0 2021-02-28 [2] CRAN (R 4.0.3)
fastmap 1.1.0 2021-01-25 [2] CRAN (R 4.0.3)
fs 1.5.0 2020-07-31 [2] CRAN (R 4.0.3)
VP generics 0.1.0 2021-10-25 [2] CRAN (R 4.0.3)
ggplot2 * 3.3.5 2021-06-25 [2] CRAN (R 4.0.3)
VP glue 1.4.2 2021-11-30 [2] CRAN (R 4.0.3)
grImport 0.9-4 2021-10-11 [2] CRAN (R 4.0.3)
gtable 0.3.0 2019-03-25 [2] CRAN (R 4.0.3)
hexbin 1.28.2 2021-01-08 [2] CRAN (R 4.0.3)
htmltools 0.5.2 2021-08-25 [2] CRAN (R 4.0.3)
jpeg 0.1-9 2021-07-24 [2] CRAN (R 4.0.3)
KernSmooth 2.23-20 2021-05-03 [4] CRAN (R 4.0.5)
knitr 1.36 2021-09-29 [2] CRAN (R 4.0.3)
labeling 0.4.2 2020-10-20 [2] CRAN (R 4.0.3)
landscapetools * 0.6.2 2021-11-30 [1] Github (ropensci/landscapetools@77d9d24)
lattice * 0.20-45 2021-09-22 [4] CRAN (R 4.1.1)
latticeExtra 0.6-29 2019-12-19 [2] CRAN (R 4.0.3)
lifecycle 1.0.1 2021-09-24 [2] CRAN (R 4.0.3)
lsr * 0.5.1 2021-09-20 [1] CRAN (R 4.0.3)
magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.0.3)
memoise 2.0.0 2021-01-26 [2] CRAN (R 4.0.3)
mobsim * 0.2.0 2021-03-23 [1] CRAN (R 4.0.3)
munsell 0.5.0 2018-06-12 [2] CRAN (R 4.0.3)
NCmisc 1.1.6 2018-11-12 [2] CRAN (R 4.0.3)
NinaR * 0.2.2.3 2020-12-10 [2] Github (NINAnor/NinaR@77dd8d1)
NLMR * 1.1 2021-11-30 [1] Github (ropensci/NLMR@3a1b03f)
oneimpact * 0.1.0 2021-11-30 [1] local
pillar 1.6.4 2021-10-18 [2] CRAN (R 4.0.3)
pkgbuild 1.2.0 2020-12-15 [2] CRAN (R 4.0.3)
pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.3)
pkgload 1.2.3 2021-10-13 [2] CRAN (R 4.0.3)
plyr 1.8.6 2020-03-03 [2] CRAN (R 4.0.3)
png 0.1-7 2013-12-03 [2] CRAN (R 4.0.3)
prettyunits 1.1.1 2020-01-24 [2] CRAN (R 4.0.3)
processx 3.5.2 2021-04-30 [1] CRAN (R 4.0.3)
proftools 0.99-3 2020-07-08 [2] CRAN (R 4.0.3)
proxy 0.4-26 2021-06-07 [2] CRAN (R 4.0.3)
ps 1.6.0 2021-02-28 [2] CRAN (R 4.0.3)
purrr 0.3.4 2020-04-17 [2] CRAN (R 4.0.3)
R6 2.5.1 2021-08-19 [2] CRAN (R 4.0.3)
raster * 3.5-2 2021-10-11 [2] CRAN (R 4.0.3)
rasterVis * 0.51.0 2021-10-11 [1] CRAN (R 4.0.3)
RColorBrewer 1.1-2 2014-12-07 [2] CRAN (R 4.0.3)
Rcpp 1.0.7 2021-07-07 [2] CRAN (R 4.0.3)
remotes 2.4.1 2021-09-29 [2] CRAN (R 4.0.3)
reshape2 * 1.4.4 2020-04-09 [2] CRAN (R 4.0.3)
rgdal 1.5-27 2021-09-16 [2] CRAN (R 4.0.3)
rlang 0.4.12 2021-10-18 [2] CRAN (R 4.0.3)
rmarkdown * 2.11 2021-09-14 [2] CRAN (R 4.0.3)
rprojroot 2.0.2 2020-11-15 [2] CRAN (R 4.0.3)
rstudioapi 0.13 2020-11-12 [2] CRAN (R 4.0.3)
scales 1.1.1 2020-05-11 [2] CRAN (R 4.0.3)
sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.3)
sf * 1.0-4 2021-11-14 [1] CRAN (R 4.0.3)
sp * 1.4-6 2021-11-14 [1] CRAN (R 4.0.3)
stringi 1.7.5 2021-10-04 [2] CRAN (R 4.0.3)
stringr 1.4.0 2019-02-10 [2] CRAN (R 4.0.3)
VP terra 1.4-11 2021-11-24 [2] CRAN (R 4.0.3)
testthat 3.1.0 2021-10-04 [2] CRAN (R 4.0.3)
VP tibble 3.1.5 2021-11-07 [2] CRAN (R 4.0.3)
tidyselect 1.1.1 2021-04-30 [2] CRAN (R 4.0.3)
units 0.7-2 2021-06-08 [2] CRAN (R 4.0.3)
usethis 2.1.0 2021-10-16 [2] CRAN (R 4.0.3)
utf8 1.2.2 2021-07-24 [2] CRAN (R 4.0.3)
vctrs 0.3.8 2021-04-29 [2] CRAN (R 4.0.3)
viridisLite 0.4.0 2021-04-13 [2] CRAN (R 4.0.3)
withr 2.4.2 2021-04-18 [2] CRAN (R 4.0.3)
xfun 0.27 2021-10-18 [2] CRAN (R 4.0.3)
XML 3.99-0.8 2021-09-17 [2] CRAN (R 4.0.3)
yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.3)
zoo 1.8-9 2021-03-09 [2] CRAN (R 4.0.3)
[1] /home/NINA.NO/bernardo.brandao/R/x86_64-pc-linux-gnu-library/4.0
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
V ── Loaded and on-disk version mismatch.
P ── Loaded and on-disk path mismatch.
I tried to fix this, give it a try:
remotes::install_github("git@github.com:ropensci/landscapetools.git", ref = "facet_ordering")
detach("package:landscapetools", unload = TRUE) # if loaded
Thanks, @bitbacchus , it works fine!
Is there a parameters controling it now, or by default the plots are showed in the order of the input list?
No, it's just the order in the list or rasterstack. I think this is intuitive and it is easy to order everything in R before plotting.