这是indexloc提供的服务,不要输入任何密码
Skip to content

improve error messages + add example for tm_legend #997

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

Merged
merged 5 commits into from
Dec 19, 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
3 changes: 2 additions & 1 deletion .covrignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
onLoad.R
onLoad.R
docs.R
4 changes: 2 additions & 2 deletions R/messages_v4_v3.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ v3_tm_scale = function(scale_fun, vv, layer_fun, arg_list) {

al = v3_list_text(olds = arg_list$old, news = arg_list$new)
cli::cli_inform(c(
"{.field [v3->v4]} {.fn {layer_fun}}: migrate the argument(s) related to the scale of the visual variable {.var {vv}} namely {al} to {vv}.scale = {scale_fun}(<HERE>).",
"{.field [v3->v4]} {.fn tm_{layer_fun}}: migrate the argument(s) related to the scale of the visual variable {.var {vv}} namely {al} to {vv}.scale = {scale_fun}(<HERE>).",
"i" = x
))
}
Expand Down Expand Up @@ -231,7 +231,7 @@ v3_tm_legend_hide = function(fun, arg, vv) {
"{.field [v3->v4]} {.fn {fun}}: use {.code {vv}.legend = tm_legend_hide()} instead of {.code {arg} = FALSE}."
),
.frequency_id = "hide-legend",
.frequency = "regularly"
.frequency = "always"
)
}

Expand Down
6 changes: 0 additions & 6 deletions R/tm_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ tm_title_out = function(text, ..., position = tm_pos_out("center", "top")) {
)))))
}

# tm_compass = function( x = 1) {
# tm_element_list(tm_element(as.list(environment()),
# subclass = c("tm_layer", "tm_compass")))
# }


#' Map component: (credits) text
#'
#' Map component that adds a text, typically used as credits
Expand Down
1 change: 0 additions & 1 deletion R/tm_facets.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ tm_facets_grid = function(rows = NULL,
#' @export
#' @rdname tm_facets
#' @param ... passed on to `tm_facets()`
#' @name tm_facets_wrap
tm_facets_wrap = function(by = "VARS__",
nrow = NA,
ncol = NA,
Expand Down
4 changes: 0 additions & 4 deletions R/tm_layers_aux.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#' (so multiple groups can be shown), and `"none"` for no control
#' (the group cannot be (de)selected).
#' @export
#' @rdname tm_basemap
#' @name tm_basemap
#' @example ./examples/tm_basemap.R
tm_basemap = function(server = NA, alpha = NULL, zoom = NULL, max.native.zoom = 17, zindex = 0, group = NA, group.control = "radio") {
if (is.null(server)) {
Expand All @@ -53,7 +51,6 @@ tm_basemap = function(server = NA, alpha = NULL, zoom = NULL, max.native.zoom =

#' @export
#' @rdname tm_basemap
#' @name tm_tiles
tm_tiles = function(server = NA, alpha = NULL, zoom = NULL, max.native.zoom = 1, zindex = NA, group = NA, group.control = "check") {
if (is.null(server)) {
disable = TRUE
Expand Down Expand Up @@ -88,7 +85,6 @@ leaflet::providers
#' @inheritDotParams tm_grid
#' @export
#' @example ./examples/tm_grid.R

tm_graticules = function(x = NA,
y = NA,
n.x = NA,
Expand Down
3 changes: 0 additions & 3 deletions R/tm_layers_cartogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ tm_cartogram_dorling = function(size = 1,
options = options), args))
}

#' @name opt_tm_cartogram
#' @rdname tm_cartogram
#' @param type cartogram type, one of: "cont" for contiguous cartogram, "ncont" for non-contiguous cartogram and "dorling" for Dorling cartograms
#' @param itermax, maximum number of iterations (see [cartogram::cartogram_cont()])
Expand All @@ -90,7 +89,6 @@ opt_tm_cartogram = function(type = "cont",
polygons = do.call(opt_tm_polygons, list(...)))
}

#' @name opt_tm_cartogram_ncont
#' @rdname tm_cartogram
#' @param expansion factor expansion, see [cartogram::cartogram_ncont()] (argument `k`)
#' @param inplace should each polygon be modified in its original place? (`TRUE` by default)
Expand All @@ -106,7 +104,6 @@ opt_tm_cartogram_ncont = function(type = "ncont",
}


#' @name opt_tm_cartogram_dorling
#' @rdname tm_cartogram
#' @param share share of the bounding box filled with the larger circle (see [cartogram::cartogram_dorling()] argument `k`)
#' @export
Expand Down
1 change: 0 additions & 1 deletion R/tm_layers_polygons.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ tm_borders = function(col = tm_const(), ...) {
#' The family of `opt_*()` functions can be used to specify options in the different `tm_*()`
#' functions.
#'
#' @name opt_tm_polygons
#' @rdname tm_polygons
#' @param polygons.only should only polygon geometries of the shape object (defined in [tm_shape()]) be plotted? By default `"ifany"`, which means `TRUE` in case a geometry collection is specified.
#' @export
Expand Down
2 changes: 0 additions & 2 deletions R/tm_layers_symbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ v3_symbols = function(args, args_called, arg_col = NULL) {


#' @export
#' @name tm_dots
#' @rdname tm_symbols
tm_dots = function(fill = tm_const(),
fill.scale = tm_scale(),
Expand Down Expand Up @@ -519,7 +518,6 @@ tm_dots = function(fill = tm_const(),


#' @export
#' @name tm_bubbles
#' @rdname tm_symbols
tm_bubbles = function(size = tm_const(),
size.scale = tm_scale(),
Expand Down
2 changes: 0 additions & 2 deletions R/tm_layers_text.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
#' @param options options passed on to the corresponding `opt_<layer_function>` function
#' @param ... to catch deprecated arguments from version < 4.0
#' @example ./examples/tm_text.R
#' @rdname tm_text
#' @name tm_text
#' @export
tm_text = function(text = tm_const(),
text.scale = tm_scale(),
Expand Down
7 changes: 0 additions & 7 deletions R/tm_layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#'
#' @inheritParams tmap_options
#' @example ./examples/tm_layout.R
#' @name tm_layout
#' @export
tm_layout = function(
scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set_bounds, set_view, set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color,
Expand Down Expand Up @@ -76,7 +75,6 @@ tm_plot = function(use_gradient) {


#' @rdname tm_extra_innner_margin
#' @name tm_place_legends_right
#' @export
tm_place_legends_right = function(width = NA) {
if (is.na(width)) {
Expand All @@ -87,7 +85,6 @@ tm_place_legends_right = function(width = NA) {
}

#' @rdname tm_extra_innner_margin
#' @name tm_place_legends_left
#' @param width width
#' @export
tm_place_legends_left = function(width = NA) {
Expand All @@ -99,7 +96,6 @@ tm_place_legends_left = function(width = NA) {
}

#' @rdname tm_extra_innner_margin
#' @name tm_place_legends_bottom
#' @param height height
#' @export
tm_place_legends_bottom = function(height = NA) {
Expand All @@ -111,7 +107,6 @@ tm_place_legends_bottom = function(height = NA) {
}

#' @rdname tm_extra_innner_margin
#' @name tm_place_legends_top
#' @export
tm_place_legends_top = function(height = NA) {
if (is.na(height)) {
Expand All @@ -122,7 +117,6 @@ tm_place_legends_top = function(height = NA) {
}

#' @rdname tm_extra_innner_margin
#' @name tm_place_legends_inside
#' @param pos.h,pos.v position (horizontal and vertical)
#' @export
tm_place_legends_inside = function(pos.h = NULL, pos.v = NULL) {
Expand All @@ -142,7 +136,6 @@ tm_place_legends_inside = function(pos.h = NULL, pos.v = NULL) {
#'
#' @param left,right,top,bottom extra margins
#' @export
#' @rdname tm_extra_innner_margin
#' @name tm_extra_innner_margin
tm_extra_innner_margin = function(left = 0, right = 0, top = 0, bottom = 0) {
tm_options(inner.margins.extra = c(bottom, left, top, right))
Expand Down
2 changes: 1 addition & 1 deletion R/tm_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' @param width Width of the legend
#' @param height Height of the legend
#' @inheritParams tm_title
#' @param resize_as_group PARAM_DESCRIPTION
#' @param title.color Color of the legend title
#' @param title.size Size of the legend title
#' @param title.fontface Font face of the legend title
Expand Down Expand Up @@ -42,6 +41,7 @@
#' @param variable visual (or transformation) variable to combine the legend with: e.g. `"fill"` or `"size"`
#' @return A tm_legend component
#' @export
#' @example ./examples/tm_legend.R
tm_legend = function(title,
show,
orientation,
Expand Down
7 changes: 0 additions & 7 deletions R/tm_pos.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,13 @@
#' (or components) will be aligned with the maps.
#'
#' @export
#' @name tm_pos
#' @rdname tm_pos
tm_pos = function(cell.h, cell.v, pos.h, pos.v, align.h, align.v, just.h, just.v) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args$type = "na"
structure(args, class = "tm_pos")
}

#' @export
#' @name tm_pos_in
#' @rdname tm_pos
tm_pos_in = function(pos.h, pos.v, align.h, align.v, just.h, just.v) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
Expand All @@ -124,7 +121,6 @@ tm_pos_in = function(pos.h, pos.v, align.h, align.v, just.h, just.v) {


#' @export
#' @name tm_pos_out
#' @rdname tm_pos
tm_pos_out = function(cell.h, cell.v, pos.h, pos.v, align.h, align.v, just.h, just.v) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
Expand All @@ -133,7 +129,6 @@ tm_pos_out = function(cell.h, cell.v, pos.h, pos.v, align.h, align.v, just.h, ju
}

#' @export
#' @name tm_pos_on_top
#' @rdname tm_pos
tm_pos_on_top = function(pos.h, pos.v, align.h, align.v, just.h, just.v) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
Expand All @@ -144,7 +139,6 @@ tm_pos_on_top = function(pos.h, pos.v, align.h, align.v, just.h, just.v) {
}

#' @export
#' @name tm_pos_auto_out
#' @rdname tm_pos
tm_pos_auto_out = function(cell.h, cell.v, pos.h, pos.v, align.h, align.v, just.h, just.v) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
Expand All @@ -153,7 +147,6 @@ tm_pos_auto_out = function(cell.h, cell.v, pos.h, pos.v, align.h, align.v, just.
}

#' @export
#' @name tm_pos_auto_in
#' @rdname tm_pos
tm_pos_auto_in = function(align.h, align.v, just.h, just.v) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
Expand Down
9 changes: 0 additions & 9 deletions R/tm_scale_.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ tm_scale_discrete = function(ticks = NA,
#' @example ./examples/tm_scale_continuous.R
#' @seealso [tm_scale()]
#' @export
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous
tm_scale_continuous = function(n = NULL,
limits = NULL,
Expand Down Expand Up @@ -300,51 +299,44 @@ tm_scale_rank = function(n = NULL,
#' @export
#' @param ... passed on to [tm_scale_continuous()]
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous_log
tm_scale_continuous_log = function(..., base = exp(1)) {
tm_scale_continuous(trans = "log", trans.args = list(base = base), ...)
}

#' @export
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous_log2
tm_scale_continuous_log2 = function(...) {
tm_scale_continuous(trans = "log", trans.args = list(base = 2), ...)
}

#' @export
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous_log10
tm_scale_continuous_log10 = function(...) {
tm_scale_continuous(trans = "log", trans.args = list(base = 10), ...)
}


#' @export
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous_log1p
tm_scale_continuous_log1p = function(...) {
tm_scale_continuous(trans = "log1p", ...)
}

#' @export
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous_sqrt
tm_scale_continuous_sqrt = function(...) {
tm_scale_continuous(trans = "sqrt", ...)
}

#' @export
#' @rdname tm_scale_continuous
#' @name tm_scale_continuous_pseudo_log
tm_scale_continuous_pseudo_log = function(..., base = exp(1), sigma = 1) {
tm_scale_continuous(trans = "pseudo_log", trans.args = list(base = base, sigma = sigma), ...)
}

#
# #' @export
# #' @rdname tm_scale_continuous
# #' @name tm_scale_continuous_logistic
# tm_scale_continuous_logistic = function(...) {
# tm_scale_continuous(trans = "logistic", ...)
# }
Expand All @@ -363,7 +355,6 @@ tm_scale_continuous_pseudo_log = function(..., base = exp(1), sigma = 1) {
#' @param probs probability (quantile) values when `stretch = "percent"`
#' @param maxColorValue maximum value
#' @seealso [tm_scale()] and [stars::st_rgb()]
#' @rdname tm_scale_rgb
#' @example ./examples/tm_scale_rgb.R
#' @export
tm_scale_rgb = function(value.na = NA,
Expand Down
Loading
Loading