Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/r-tmap/tmap

# Conflicts:
#	R/tm_layers_text.R
#	man/tm_text.Rd
  • Loading branch information
mtennekes committed Mar 18, 2024
2 parents 370b415 + 9e76b33 commit f212fd3
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 64 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tmap
Title: Thematic Maps
Version: 3.99.9000
Version: 3.99.9001
Authors@R: c(
person("Martijn", "Tennekes", , "mtennekes@gmail.com", role = c("aut", "cre")),
person("Jakub", "Nowosad", , "nowosad.jakub@gmail.com", role = "ctb"),
Expand All @@ -25,7 +25,7 @@ Depends:
R (>= 3.5.0)
Imports:
classInt (>= 0.4-3),
cols4all (>= 0.7),
cols4all (>= 0.7-1),
data.table,
grid,
htmltools,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ S3method(tmapLeafletCompWidth,tm_legend_standard_portrait)
S3method(tmapLeafletCompWidth,tm_mouse_coordinates)
S3method(tmapLeafletCompWidth,tm_scalebar)
S3method(tmapLeafletCompWidth,tm_title)
S3method(tmapLeafletLegPlot,tm_chart)
S3method(tmapLeafletLegPlot,tm_chart_histogram)
S3method(tmapLeafletLegPlot,tm_compass)
S3method(tmapLeafletLegPlot,tm_credits)
Expand Down
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: 1 addition & 1 deletion R/step4_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ step4_plot = function(tm, vp, return.asp, show, knit, args) {
# prepare aux layers and return group label (in case it is not user specified)
aux_group_def = mapply(function(a, id) {
FUNaux_prep = paste0("tmap", gs, a$mapping.fun, "Prep")
do.call(FUNaux_prep, list(a = a$args, b = db$bbox, id = id, o = o))
do.call(FUNaux_prep, list(a = a$args, bs = db$bbox, id = id, o = o))
}, aux, 1:length(aux))
aux_group = mapply(function(a, agd) {
if (is.na(a$group)) agd else as.character(a$group)
Expand Down
1 change: 0 additions & 1 deletion R/tm_layers_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
#' @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 Rotation angle
#' the background color. See Details.
#' @param points.only should only point geometries of the shape object (defined in [tm_shape()]) be plotted? By default `"ifany"`, which means `TRUE` in case a geometry collection is specified.
#' @param along.lines logical that determines whether labels are rotated along the spatial lines. Only applicable if a spatial lines shape is used.
#' @param clustering value that determines whether the text labels are clustered in \code{"view"} mode. One of: \code{TRUE}, \code{FALSE}, or the output of \code{\link[leaflet:markerClusterOptions]{markerClusterOptions}}.
Expand Down
5 changes: 5 additions & 0 deletions R/tmapLeafletComp_charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ tmapLeafletCompHeight.tm_chart = function(comp, o) {
tmapLeafletLegPlot.tm_chart_histogram = function(comp, lf, o) {
lf
}
#' @method tmapLeafletLegPlot tm_chart
#' @export
tmapLeafletLegPlot.tm_chart = function(comp, lf, o) {
lf
}
2 changes: 1 addition & 1 deletion R/tmapLeafletLegend.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ tmapLeaflet_legend = function(cmp, lf, o, orientation) {

legpos = leaflet_pos(cmp$position)

lf2 = if (cmp$typ == "none") {
lf2 = if (cmp$type == "none") {
#message("Text based legends not supported in view mode")
lf
} else if (cmp$type == "gradient") {
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,11 +30,13 @@ 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())

DE = World[World$name == "Germany",]
rivers_DE = st_intersection(rivers, DE)
Expand Down
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.

9 changes: 5 additions & 4 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 f212fd3

Please sign in to comment.