Skip to content

Commit

Permalink
address notes
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Mar 15, 2024
1 parent 354284d commit 378f421
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 55 deletions.
3 changes: 2 additions & 1 deletion R/global-variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
))
2 changes: 2 additions & 0 deletions R/tm_layers_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions R/v4-not-implemented.R
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
49 changes: 27 additions & 22 deletions examples/tm_chart.R
Original file line number Diff line number Diff line change
@@ -1,51 +1,56 @@
## 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",
col.chart = tm_chart_histogram())

## 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) +
Expand Down
6 changes: 4 additions & 2 deletions examples/tm_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())

49 changes: 27 additions & 22 deletions man/tm_chart.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/tm_text.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions man/v4-not-yet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions vignettes/tmap_vv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -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:

Expand All @@ -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.

Expand Down

0 comments on commit 378f421

Please sign in to comment.