From 060e7a7b7c45e72b4f4464d0018cc176ab71025a Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 20 Sep 2023 09:50:43 -0400 Subject: [PATCH 1/4] Specifically ask for maptiles and cartogram as they are suggests. --- examples/tm_basemap.R | 16 +++++++++------- man/tm_basemap.Rd | 16 +++++++++------- tests/testthat/test-v3.R | 2 +- vignettes/tmap_sneak_peek.Rmd | 4 ++++ vignettes/tmap_vv.Rmd | 4 ++++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/tm_basemap.R b/examples/tm_basemap.R index 37f2dc1b..d5091f0c 100644 --- a/examples/tm_basemap.R +++ b/examples/tm_basemap.R @@ -1,7 +1,9 @@ -tm_basemap() + - tm_shape(World) + - tm_polygons("HPI") - -tm_basemap("OpenTopoMap") + - tm_shape(World) + - tm_polygons(fill = NA, col = "black") +if (requireNamespace("maptiles")) { + tm_basemap() + + tm_shape(World) + + tm_polygons("HPI") + + tm_basemap("OpenTopoMap") + + tm_shape(World) + + tm_polygons(fill = NA, col = "black") +} diff --git a/man/tm_basemap.Rd b/man/tm_basemap.Rd index 0fbea8ba..5b88cd2f 100644 --- a/man/tm_basemap.Rd +++ b/man/tm_basemap.Rd @@ -40,11 +40,13 @@ tm_tiles( Map layer that draws tiles from a tile server. \code{tm_basemap()} draws the tile layer as basemap, i.e. as bottom layer. In contrast, \code{tm_tiles()} draws the tile layer as overlay layer, where the stacking order corresponds with the order in which this layer is called, just like other map layers. } \examples{ -tm_basemap() + - tm_shape(World) + - tm_polygons("HPI") - -tm_basemap("OpenTopoMap") + - tm_shape(World) + - tm_polygons(fill = NA, col = "black") +if (requireNamespace("maptiles")) { + tm_basemap() + + tm_shape(World) + + tm_polygons("HPI") + + tm_basemap("OpenTopoMap") + + tm_shape(World) + + tm_polygons(fill = NA, col = "black") +} } diff --git a/tests/testthat/test-v3.R b/tests/testthat/test-v3.R index a92772c4..bb9bb172 100644 --- a/tests/testthat/test-v3.R +++ b/tests/testthat/test-v3.R @@ -39,7 +39,7 @@ test_that("v3 syntax works", { tm_shape(NLD_prov) + tm_fill("name", legend.show = FALSE) + tm_shape(NLD_muni) + - tm_polygons("MAP_COLORS", palette = "Greys", alpha = .25) + + tm_polygons("MAP_COLORS", palette = "Grays", alpha = .25) + tm_shape(NLD_prov) + tm_borders(lwd = 2) + tm_text("name", shadow = TRUE) + diff --git a/vignettes/tmap_sneak_peek.Rmd b/vignettes/tmap_sneak_peek.Rmd index 3f75f453..7e297ec2 100644 --- a/vignettes/tmap_sneak_peek.Rmd +++ b/vignettes/tmap_sneak_peek.Rmd @@ -139,12 +139,14 @@ In **tmap v4**, there will be a direct function `tm_cartogram()` (using the **ca ```{r, class.source='bg-success', message=FALSE} # tmap v4 +if (requireNamespace("cartogram")) { tm_shape(World, crs = "+proj=eck4") + tm_cartogram(size = "pop_est", fill = "HPI", fill.scale = tm_scale_intervals(values = "purple_green"), fill.legend = tm_legend(title = "Happy Planet Index")) + tm_place_legends_right(width = 0.2) +} ``` @@ -168,6 +170,7 @@ tm_shape(World_carto) + ```{r, class.source='bg-success',message=FALSE} # tmap v4 +if (requireNamespace("cartogram")) { tm_shape(World, crs = "+proj=eck4") + tm_cartogram(size = "pop_est", size.scale = tm_scale_continuous_log1p(), @@ -175,6 +178,7 @@ tm_shape(World, crs = "+proj=eck4") + fill.scale = tm_scale_intervals(values = "purple_green"), fill.legend = tm_legend(title = "Happy Planet Index")) + tm_place_legends_right(width = 0.2) +} ``` ## Scales diff --git a/vignettes/tmap_vv.Rmd b/vignettes/tmap_vv.Rmd index 49fc880b..3edb96a2 100644 --- a/vignettes/tmap_vv.Rmd +++ b/vignettes/tmap_vv.Rmd @@ -112,12 +112,14 @@ For those who are completely new to **tmap**: the function `tm_shape()` specifie In the next example we have three layers: a basemap from OpenTopoMap, country polygon boundaries, and dots for metropolitan areas: ```{r} +if (requireNamespace("maptiles")) { tm_basemap(server = "OpenTopoMap", zoom = 2, alpha = 0.5) + tm_shape(World, bbox = sf::st_bbox(c(xmin = -180, xmax = 180, ymin = -86, ymax = 86))) + tm_polygons(fill = NA, col = "black") + tm_shape(metro) + tm_symbols(size = 0.1, col = "red") + tm_layout(inner.margins = rep(0, 4)) +} ``` Each visual variable argument can also be specified with a data variable (e.g., a column name). What happens in that case is that the values of data variable are mapped to values of the corresponding visual variable. @@ -152,8 +154,10 @@ This map uses a continuous color scale with colors from CARTO. More on scales la Besides visual variables, map layer may use spatial transformation variables. ```{r} +if (requireNamespace("cartogram")) { tm_shape(World, crs = 8857) + tm_cartogram(size = "pop_est", fill = "income_grp") +} ``` We used two variables: `size` to deform the polygons using a continuous cartogram and `fill` to color the polygons. From 79b8eb0f84eb57fd4e70790719744d798e31422f Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 20 Sep 2023 09:50:59 -0400 Subject: [PATCH 2/4] Enable development mode for website. --- _pkgdown.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_pkgdown.yml b/_pkgdown.yml index 0f3eb590..1d72260d 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -2,3 +2,5 @@ url: https://r-tmap.github.io/tmap/ template: bootstrap: 5 +development: + mode: auto From 16a873f69a14372ccd298ec359640c0cbe77e4a7 Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 20 Sep 2023 10:07:54 -0400 Subject: [PATCH 3/4] indent --- _pkgdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index 1d72260d..fd0ee4ac 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -3,4 +3,4 @@ template: bootstrap: 5 development: - mode: auto + mode: auto From 02859c73db88030e867da49ba3b69ca30cc02c02 Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 20 Sep 2023 12:22:10 -0400 Subject: [PATCH 4/4] Use custom color based on logo --- _pkgdown.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_pkgdown.yml b/_pkgdown.yml index fd0ee4ac..5f8581c0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,6 +1,8 @@ url: https://r-tmap.github.io/tmap/ template: bootstrap: 5 + bslib: + primary: "#5f8640" development: mode: auto