diff --git a/R/global-variables.R b/R/global-variables.R index c6f7aa2d..0f939b65 100644 --- a/R/global-variables.R +++ b/R/global-variables.R @@ -30,5 +30,6 @@ utils::globalVariables(c( "legend.bg.alpha", "lin", "m", "n", "overlays_tiles", "show", "show.labels", "show.warnings", "total", "trans.args", "type", "values", "xlab.rotation", "xlab.show", "xlab.side", "xlab.space", "xlab.text", "ylab.rotation", - "ylab.show", "ylab.side", "ylab.space", "ylab.text", "z" + "ylab.show", "ylab.side", "ylab.space", "ylab.text", "z", + "x", "y", "color", "freq", "bin", "bin1", "bin2" )) diff --git a/R/tm_layers_text.R b/R/tm_layers_text.R index 9d6f0c0e..0745e09f 100644 --- a/R/tm_layers_text.R +++ b/R/tm_layers_text.R @@ -60,6 +60,8 @@ #' @param xmod,xmod.scale,xmod.legend,xmod.chart,xmod.free Transformation variable that determines the x offset. See details. #' @param ymod,ymod.scale,ymod.legend,ymod.chart,ymod.free Transformation variable that determines the y offset. See details. #' the text. See details. +#' @param angle,angle.scale,angle.legend,angle.chart,angle.free Transformations +#' variables that determine the angle of the text #' @param ... to catch deprecated arguments from version < 4.0 #' @example ./examples/tm_text.R #' @export diff --git a/R/v4-not-implemented.R b/R/v4-not-implemented.R index ac0157f3..d7082867 100644 --- a/R/v4-not-implemented.R +++ b/R/v4-not-implemented.R @@ -1,11 +1,17 @@ +#' Features not yet implemented in tmap4 +#' +#' @param ... Arguments +#' @name v4-not-yet +NULL + #' @export #' @rdname v4-not-yet -tm_iso <- function() { +tm_iso <- function(...) { stop("Not yet implemented in v4") } #' @export #' @rdname v4-not-yet -tm_markers <- function() { +tm_markers <- function(...) { stop("Not yet implemented in v4") } #' @export @@ -15,7 +21,7 @@ tm_logo <- function(...) { } #' @export #' @rdname v4-not-yet -tm_minimap <- function() { +tm_minimap <- function(...) { stop("Not yet implemented in v4") } #' @export diff --git a/examples/tm_chart.R b/examples/tm_chart.R index 612d8d5b..ea5f358d 100644 --- a/examples/tm_chart.R +++ b/examples/tm_chart.R @@ -1,36 +1,41 @@ ## numerical variable tm_shape(World) + - tm_polygons ("HPI", + tm_polygons("HPI", fill.scale = tm_scale_intervals(), fill.chart = tm_chart_histogram()) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_continuous(), - fill.chart = tm_chart_histogram(position = tm_pos_out("center", "bottom"), width = 30)) + tm_polygons("HPI", + fill.scale = tm_scale_continuous(), + fill.chart = tm_chart_histogram( + position = tm_pos_out("center", "bottom"), + width = 30) + ) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_donut()) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_donut()) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_box()) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_box()) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_violin()) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_violin()) # with additional ggplot2 code require(ggplot2) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_bar(extra.ggplot2 = theme(panel.grid.major.y = element_line(colour = "red")))) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_bar( + extra.ggplot2 = theme(panel.grid.major.y = element_line(colour = "red"))) + ) tm_shape(land) + tm_raster("trees", @@ -38,14 +43,14 @@ tm_shape(land) + ## categorical variable tm_shape(World) + - tm_polygons ("economy", - fill.scale = tm_scale_categorical(), - fill.chart = tm_chart_bar()) + tm_polygons("economy", + fill.scale = tm_scale_categorical(), + fill.chart = tm_chart_bar()) tm_shape(World) + - tm_polygons ("economy", - fill.scale = tm_scale_categorical(), - fill.chart = tm_chart_donut()) + tm_polygons("economy", + fill.scale = tm_scale_categorical(), + fill.chart = tm_chart_donut()) # bivariate (in development) tm_shape(World) + diff --git a/examples/tm_text.R b/examples/tm_text.R index 105d816b..cd09ee2b 100644 --- a/examples/tm_text.R +++ b/examples/tm_text.R @@ -30,9 +30,11 @@ tm_shape(metro) + tm_shape(World) + tm_polygons() + tm_shape(metro) + - tm_text(text = "name", size = "pop2020", angle = -30, shadow = TRUE) + tm_text(text = "name", size = "pop2020", + angle = -30, shadow = TRUE) metro$upside_down = ifelse(sf::st_coordinates(metro)[,2] < 0, 180, 0) tm_shape(metro) + - tm_text(text = "name", size = "pop2020", angle = "upside_down", size.legend = tm_legend_hide()) + tm_text(text = "name", size = "pop2020", + angle = "upside_down", size.legend = tm_legend_hide()) diff --git a/man/tm_chart.Rd b/man/tm_chart.Rd index e24fec9d..3d87ed13 100644 --- a/man/tm_chart.Rd +++ b/man/tm_chart.Rd @@ -94,36 +94,41 @@ Note that these charts are different from charts drawn inside the map. Those are ## numerical variable tm_shape(World) + - tm_polygons ("HPI", + tm_polygons("HPI", fill.scale = tm_scale_intervals(), fill.chart = tm_chart_histogram()) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_continuous(), - fill.chart = tm_chart_histogram(position = tm_pos_out("center", "bottom"), width = 30)) + tm_polygons("HPI", + fill.scale = tm_scale_continuous(), + fill.chart = tm_chart_histogram( + position = tm_pos_out("center", "bottom"), + width = 30) + ) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_donut()) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_donut()) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_box()) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_box()) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_violin()) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_violin()) # with additional ggplot2 code require(ggplot2) tm_shape(World) + - tm_polygons ("HPI", - fill.scale = tm_scale_intervals(), - fill.chart = tm_chart_bar(extra.ggplot2 = theme(panel.grid.major.y = element_line(colour = "red")))) + tm_polygons("HPI", + fill.scale = tm_scale_intervals(), + fill.chart = tm_chart_bar( + extra.ggplot2 = theme(panel.grid.major.y = element_line(colour = "red"))) + ) tm_shape(land) + tm_raster("trees", @@ -131,14 +136,14 @@ tm_shape(land) + ## categorical variable tm_shape(World) + - tm_polygons ("economy", - fill.scale = tm_scale_categorical(), - fill.chart = tm_chart_bar()) + tm_polygons("economy", + fill.scale = tm_scale_categorical(), + fill.chart = tm_chart_bar()) tm_shape(World) + - tm_polygons ("economy", - fill.scale = tm_scale_categorical(), - fill.chart = tm_chart_donut()) + tm_polygons("economy", + fill.scale = tm_scale_categorical(), + fill.chart = tm_chart_donut()) # bivariate (in development) tm_shape(World) + diff --git a/man/tm_text.Rd b/man/tm_text.Rd index e8783d9a..c8ee2fd5 100644 --- a/man/tm_text.Rd +++ b/man/tm_text.Rd @@ -51,6 +51,11 @@ tm_text( ymod.legend = tm_legend_hide(), ymod.chart = tm_chart_none(), ymod.free = NA, + angle = 0, + angle.scale = tm_scale(), + angle.legend = tm_legend_hide(), + angle.chart = tm_chart_none(), + angle.free = NA, shadow = FALSE, plot.order = tm_plot_order("AREA", reverse = FALSE, na.order = "bottom"), trans.args = list(points.only = "ifany"), @@ -90,6 +95,9 @@ the background color transparency. See Details.} \item{ymod, ymod.scale, ymod.legend, ymod.chart, ymod.free}{Transformation variable that determines the y offset. See details. the text. See details.} +\item{angle, angle.scale, angle.legend, angle.chart, angle.free}{Transformations +variables that determine the angle of the text} + \item{shadow}{Shadow behind the text. Logical or color.} \item{plot.order}{Specification in which order the spatial features are drawn. @@ -160,6 +168,9 @@ tm_shape(World) + bgcol_alpha = "pop_est", bgcol_alpha.scale = tm_scale_intervals(style = "kmeans")) +tm_shape(metro) + + tm_text(text = "name", size = "pop2020", size.legend = tm_legend_hide()) + ## xymod metro$initial = substr(metro$name,1,1) metro$az = (match(metro$initial, LETTERS)-1) /25 @@ -168,4 +179,16 @@ tm_shape(metro) + tm_dots("red") + tm_text("initial", ymod = "az") +# angle +tm_shape(World) + + tm_polygons() + +tm_shape(metro) + + tm_text(text = "name", size = "pop2020", + angle = -30, shadow = TRUE) + +metro$upside_down = ifelse(sf::st_coordinates(metro)[,2] < 0, 180, 0) +tm_shape(metro) + + tm_text(text = "name", size = "pop2020", + angle = "upside_down", size.legend = tm_legend_hide()) + } diff --git a/man/v4-not-yet.Rd b/man/v4-not-yet.Rd new file mode 100644 index 00000000..2f6df3d2 --- /dev/null +++ b/man/v4-not-yet.Rd @@ -0,0 +1,51 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/v4-not-implemented.R +\name{v4-not-yet} +\alias{v4-not-yet} +\alias{tm_iso} +\alias{tm_markers} +\alias{tm_logo} +\alias{tm_minimap} +\alias{tmap_grob} +\alias{tmapOutput} +\alias{tmapProxy} +\alias{renderTmap} +\alias{tm_remove_layer} +\alias{tm_rgba} +\alias{tmap_tip} +\alias{tmap_style_catalog} +\alias{tmap_style_catalogue} +\title{Features not yet implemented in tmap4} +\usage{ +tm_iso(...) + +tm_markers(...) + +tm_logo(...) + +tm_minimap(...) + +tmap_grob(...) + +tmapOutput(...) + +tmapProxy(...) + +renderTmap(...) + +tm_remove_layer(...) + +tm_rgba(...) + +tmap_tip(...) + +tmap_style_catalog(...) + +tmap_style_catalogue(...) +} +\arguments{ +\item{...}{Arguments} +} +\description{ +Features not yet implemented in tmap4 +} diff --git a/vignettes/tmap_vv.Rmd b/vignettes/tmap_vv.Rmd index d47e9bc9..f73e483d 100644 --- a/vignettes/tmap_vv.Rmd +++ b/vignettes/tmap_vv.Rmd @@ -12,7 +12,7 @@ output: link-citations: yes vignette: > \usepackage[utf8]{inputenc} - %\VignetteIndexEntry{tmap: visual variables} + %\VignetteIndexEntry{tmap: charts} %\VignetteEngine{knitr::rmarkdown} editor_options: chunk_output_type: console @@ -31,9 +31,9 @@ data(World, metro, rivers, land) ## Introduction -**tmap** is an R package for spatial data visualization. This vignette describes the alpha version of the major update (version 4), which will be on CRAN in the course of 2023. +**tmap** is an R package for spatial data visualization. This vignette describes the alpha version of the major update (version 4), which will be on CRAN in the course of 2024. -#### tmap 4 - tmap 3.x +### tmap 4 - tmap 3.x * **tmap 3.x** supports several map layer variables, for example `"col"`, `"size"`, and `"shape"` for the `tm_symbols()` map layer function. There will be many more of those variables in **tmap 4**. Besides the visual variables, so-called transformation variables also will be available. A *transformation variable* role is to change the spatial coordinates (for instance, to create a cartogram). A *visual variable* only changes the appearance of a spatial object, e.g. fill color or line width. You can find some examples of these variables below. @@ -51,7 +51,7 @@ data(World, metro, rivers, land) * It is possible to combine legends, which is useful if the same data variable is applied for multiple visual variables using the same scaling function. -#### tmap 4 - ggplot2 +### tmap 4 - ggplot2 The **tmap** package is very similar to **ggplot2** and its Grammar of Graphics, but tailored to spatial data visualization, whereas **ggplot2** is much more general. More specifically: @@ -65,7 +65,7 @@ The **tmap** package is very similar to **ggplot2** and its Grammar of Graphics, * ... -#### tmap 4 - other R packages +### tmap 4 - other R packages There are several great R packages for spatial data visualization, including: **ggplot2**, **mapview**, **leaflet**, **mapsf**, and the generic plot function.