Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address notes #846

Merged
merged 4 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,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.

Loading