diff --git a/_pkgdown.yml b/_pkgdown.yml index 0f3eb590..5f8581c0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,8 @@ url: https://r-tmap.github.io/tmap/ template: bootstrap: 5 + bslib: + primary: "#5f8640" +development: + mode: auto 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.