Skip to contents

Parameters to customize caption defaults.

Usage

set_caption(
  text = NA,
  ...,
  template = getOption("roboplot.caption.template"),
  xref = getOption("roboplot.caption.xref"),
  font = NULL
)

Arguments

text

Character. The text used in the template (make sure the template has the parameter text).

...

Other parameters to be passed to template.

template

Character. Template for stringr::str_glue() used to parse the caption with the given parameters. Must contain the parameter `text.

xref

Character. Either "container" or "plot". Determines if the caption is anchored to the plot or the container edge. Ignored for robotable() and robomap().

font

Call. Use set_font() to set font parameters for the caption. Currently only supports for global settings through set_roboplot_options(caption).

Value

A list of class roboplot.set_caption

Examples

# Used to define how captions are constructed inside `roboplot()`. The used
# parameters are used inside stringr::str_glue() to parse a caption
# string. You can skip using `set_caption()` simply by giving a character string.
# You can provide the template here, or use the one defined globally with
# `set_roboplot_options()`.


d <- energiantuonti |> dplyr::filter(Alue == "USA",Suunta == "Tuonti")

d |> roboplot(Alue,"Energian tuonti Yhdysvalloista","Milj. €",
                   caption = "Tilastokeskus")
# Anchor the caption to the left edge of the container instead of the plot with # `xref`. You probably want to do the same for title, but you don't have to. d |> roboplot(Alue, title = set_title("Energian tuonti Yhdysvalloista", xref = "container"), caption = set_caption("Tilastokeskus", xref = "container") )
# Override the global template with function parameters and provide # parameters for it. The example is unnecessarily complicated, but gives the # idea how this could work. d |> roboplot(Alue, "Energy import","Million euros", caption = set_caption( prepend = "(Canada)", append = paste0("(Customs Finland, International trade ", "statistics;<br>Radiation and Nuclear Safety ", "Authority; Gasum LLC)"), caption = "Statistics Finland", template = "{prepend}.<br>Source: {caption}.<br>{append}." ) )
# If you need to make manual changes repeatedly, you are probably better off # using `set_roboplot_options()` to change the defaults to something more sensible. set_roboplot_options( caption_template = "Source: {text}.", ) d |> roboplot(Alue,"Energy import from Canada","M€", "Statistic Finland")
# Revert to defaults: set_roboplot_options(reset = TRUE) # Finally, don't use a caption by providing NA. d |> roboplot(Alue, "Energin tuonti Kanadasta", "Milj €", caption = NA)