Skip to content

Commit

Permalink
fixed #996, added alpha to text items
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Dec 30, 2024
1 parent 08b90f4 commit 85eff16
Show file tree
Hide file tree
Showing 23 changed files with 338 additions and 117 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export(tm_labels)
export(tm_labels_highlighted)
export(tm_layout)
export(tm_legend)
export(tm_legend_bivariate)
export(tm_legend_combine)
export(tm_legend_hide)
export(tm_lines)
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
36 changes: 18 additions & 18 deletions R/tm_components.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#'
#' Map component that adds a title
#'
#' @param text text of the title
#' @param size font size of the title
#' @param color font color of the title
#' @param text text
#' @param size font size
#' @param color font color
#' @param padding padding
#' @param fontface font face, bold, italic
#' @param fontfamily font family
#' @param alpha alpha transparency of the text
#' @param stack stack
#' @param just just
#' @param frame frame
Expand All @@ -16,12 +17,12 @@
#' @param bg.color Background color
#' @param bg.alpha Background transparency
#' @param position Vector of two values, specifying the x and y coordinates. The first is either `"left"` or `"right"`, the second either `"top"` or `"bottom"`.
#' @param width,height width and height of the title box.
#' @param width,height width and height of the text box.
#' @param group.frame group.frame
#' @param resize_as_group resize_as_group
#' @param z z
#' @export
tm_title = function(text, size, color, padding, fontface, fontfamily, stack, just, frame, frame.lwd, frame.r, bg.color, bg.alpha, position, width, height, group.frame, resize_as_group, z) {
tm_title = function(text, size, color, padding, fontface, fontfamily, alpha, stack, just, frame, frame.lwd, frame.r, bg.color, bg.alpha, position, width, height, group.frame, resize_as_group, z) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
if (!("z" %in% names(args))) args$z = NA_integer_
tm_element_list(do.call(tm_element, c(args, list(subclass = c("tm_title", "tm_component")))))
Expand Down Expand Up @@ -50,22 +51,19 @@ tm_title_out = function(text, ..., position = tm_pos_out("center", "top")) {

#' Map component: (credits) text
#'
#' Map component that adds a text, typically used as credits
#' Map component that adds a text, typically used as credits. This function is the same as [tm_title()] but with different default values.
#'
#' @param text text of the credit title
#' @param size font size of the credit title
#' @param color color
#' @param padding padding
#' @param stack stack
#' @param just just
#' @param frame.lwd frame.lwd
#' @inheritParams tm_title
#' @param group.frame group.frame
#' @param resize_as_group resize_as_group
#' @param ... to catch deprecated arguments
#' @export
tm_credits = function(text, size, color, padding, fontface, fontfamily, stack, just, frame, frame.lwd, frame.r, bg.color, bg.alpha, position, width, height, group.frame, resize_as_group, z) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
tm_credits = function(text, size, color, padding, fontface, fontfamily, alpha, stack, just, frame, frame.lwd, frame.r, bg.color, bg.alpha, position, width, height, group.frame, resize_as_group, z, ...) {
args = lapply(as.list(rlang::call_match(dots_expand = TRUE)[-1]), eval, envir = parent.frame())
if (!("z" %in% names(args))) args$z = NA_integer_
if ("align" %in% names(args)) {
args$position = tm_pos_in(pos.h = "right", pos.v = "bottom", align.h = args$align, align.v = "top", just.h = "left", just.v = "bottom")
args$align = NULL
v3_instead_message("align", "position = tm_pos_in(align.h)", "tm_credits")
}
tm_element_list(do.call(tm_element, c(args, list(subclass = c("tm_credits", "tm_component")))))
}

Expand All @@ -88,6 +86,7 @@ tm_credits = function(text, size, color, padding, fontface, fontfamily, stack, j
#' @param stack stack
#' @param just just
#' @param margins margins
#' @param ... to catch deprecated arguments (alpha)
#' @export
tm_compass <- function(north,
type,
Expand All @@ -108,7 +107,8 @@ tm_compass <- function(north,
frame.lwd,
frame.r,
margins,
z) {
z,
...) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
if (!("z" %in% names(args))) args$z = NA_integer_
tm_element_list(do.call(tm_element, c(args, list(subclass = c("tm_compass", "tm_component")))))
Expand Down
2 changes: 1 addition & 1 deletion R/tm_layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @example ./examples/tm_layout.R
#' @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.absolute_fontsize, 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,
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.alpha, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.alpha, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, text.alpha, 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.title.alpha, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.xlab.alpha, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.ylab.alpha, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.text.alpha, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.absolute_fontsize, 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.title.alpha, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.xlab.alpha, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.ylab.alpha, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.text.alpha, 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.alpha, 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.alpha, 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.alpha, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, 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,
title = NULL,
...

Expand Down
24 changes: 24 additions & 0 deletions R/tm_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
#' @param title.size `r .doc_opt("legend.title.size")`
#' @param title.fontface `r .doc_opt("legend.title.fontface")`
#' @param title.fontfamily `r .doc_opt("legend.title.fontfamily")`
#' @param title.alpha `r .doc_opt("legend.title.alpha")`
#' @param title.padding `r .doc_opt("legend.title.padding")`
#' @param title.align `r .doc_opt("legend.title.align")`
#' @param text.color `r .doc_opt("legend.text.color")`
#' @param text.size `r .doc_opt("legend.text.size")`
#' @param text.fontface `r .doc_opt("legend.text.fontface")`
#' @param text.fontfamily `r .doc_opt("legend.text.fontfamily")`
#' @param text.alpha `r .doc_opt("legend.text.alpha")`
#' @param format Not used anymore: use the format argument of the `tm_scale_*()` functions instead.
#' @param bg.color `r .doc_opt("legend.bg.color")`
#' @param bg.alpha `r .doc_opt("legend.bg.alpha")`
Expand Down Expand Up @@ -60,12 +62,14 @@ tm_legend = function(title,
title.size,
title.fontface,
title.fontfamily,
title.alpha,
title.padding,
title.align,
text.color,
text.size,
text.fontface,
text.fontfamily,
text.alpha,
format,
frame,
frame.lwd,
Expand Down Expand Up @@ -108,18 +112,38 @@ tm_legend_combine = function(variable) {
structure(list(FUN = "tmapLegend", title = NA, reverse = FALSE, show = FALSE, aes = variable), class = c("tm_legend", "tm_component", "list"))
}

#' @rdname tm_legend
#' @param xlab label for the x dimension (rows)
#' @param ylab label for the y dimension (columns)
#' @param xlab.color `r .doc_opt("legend.xlab.color")`
#' @param xlab.size `r .doc_opt("legend.xlab.size")`
#' @param xlab.fontface `r .doc_opt("legend.xlab.fontface")`
#' @param xlab.fontfamily `r .doc_opt("legend.xlab.fontfamily")`
#' @param xlab.alpha `r .doc_opt("legend.xlab.alpha")`
#' @param xlab.padding `r .doc_opt("legend.xlab.padding")`
#' @param xlab.align `r .doc_opt("legend.xlab.align")`
#' @param ylab.color `r .doc_opt("legend.ylab.color")`
#' @param ylab.size `r .doc_opt("legend.ylab.size")`
#' @param ylab.fontface `r .doc_opt("legend.ylab.fontface")`
#' @param ylab.fontfamily `r .doc_opt("legend.ylab.fontfamily")`
#' @param ylab.alpha `r .doc_opt("legend.ylab.alpha")`
#' @param ylab.padding `r .doc_opt("legend.ylab.padding")`
#' @param ylab.align `r .doc_opt("legend.ylab.align")`
#' @export
tm_legend_bivariate = function(xlab,
ylab,
xlab.color,
xlab.size,
xlab.fontface,
xlab.fontfamily,
xlab.alpha,
xlab.padding,
xlab.align,
ylab.color,
ylab.size,
ylab.fontface,
ylab.fontfamily,
ylab.alpha,
ylab.padding,
ylab.align,
...) {
Expand Down
Loading

0 comments on commit 85eff16

Please sign in to comment.