Parameters to add and customize the various options of used by roboplotr
.
Usage
set_roboplot_options(
accessible = NULL,
artefacts = NULL,
border = NULL,
background_color = NULL,
caption = NULL,
caption_template,
dashtypes = NULL,
font_main = NULL,
font_title = NULL,
font_caption = NULL,
grid = NULL,
height = NULL,
imgdl_wide = NULL,
imgdl_narrow = NULL,
imgdl_small = NULL,
infobox = NULL,
linewidth = NULL,
locale = NULL,
logo_file = NULL,
markers = NULL,
modebar = NULL,
override_webshot = NULL,
name = NULL,
patterns = NULL,
rounding = NULL,
tidy_legend = NULL,
title = NULL,
trace_border = NULL,
trace_colors = NULL,
xaxis_ceiling = NULL,
zeroline = NULL,
zoom = NULL,
verbose = NULL,
width = NULL,
shinyapp = NULL,
reset = NULL,
.defaults
)
Arguments
- accessible
Logical. Forces trace colors accessible against plot background.
- artefacts
Function. Control html and other file creation. Use
set_artefacts()
.- border
Function. Control plot borders. Use
set_border()
.- background_color
Character. Plot background color. Must be a hexadecimal color or a valid css color.
Function. Controls caption defaults. Param
template
is used withstringr::str_glue()
to parse captions. Paramxref
is used to control caption's left anchoring, and is ignored byrobomap()
androbotable()
. Useset_caption()
.Deprecated. Use caption instead.
- dashtypes
Character vector. Line trace linetypes in order of usage. Must contain all of "solid", "dash", "dot", "longdash", "dashdot", and "longdashdot" in any order.
Functions. Use
set_font()
.- grid
Function. Control the grid behind the traces. Use
set_grid()
.- height, width
Double. Height and width of roboplotr plots in pixels. Use NA for viewport size.
- imgdl_wide, imgdl_narrow, imgdl_small
Functions. Use set_imgdl_layout. Controls the dimensions and fonts of exports through modebar.
- infobox
Function. Defines the appearance of the infobox when
info_text
is provided for roboplots or robotables. Useset_infobox()
.- linewidth
Numeric. The default
roboplot()
line trace width.- locale
Function. Defines locale parameters as
roboplotr
needs them. Useset_locale()
.- logo_file
Character. The filepath to the logo used in every plot. Use "none" for no logo.
- markers
Function. Control marker appearance. Use
set_markers()
.- modebar
Character vector or function. Use
set_modebar()
, or provide the buttons contained in modebar in the given order. Must contain any of "home", "closest", "compare", "zoomin", "zoomout", "img_w", "img_n", "img_s", "data_dl" and "robonomist" in any order.- override_webshot
Logical. Overrides webshot screenshot function. Use when you want to automate pdf file creation from
roboplot()
. Other uses are fine without.- name
Character. Saves the current roboplot options as defaults for future calls of
set_roboplot_options(reset)
orroboplot(roboplot_options)
.- patterns
Character vector. Line trace linetypes in order of usage. Must contain all of "", "/", "\", "x", "-", "|", "+" and "." in any order.
- rounding
Double. Default rounding for numeric values across various roboplotr functions.
- tidy_legend
Logical. Controls whether the legend items will have matching widths, making for neater legends, or containing text widths, saving space.
- title
Function. Controls title defaults. Param
include
controls whether the title is included in html. Paramxref
is used to control title's left anchoring, and is ignored byrobomap()
androbotable()
. Useset_title()
.- trace_border
List. Borders for bars, pies and markers. Values must be named "color" and "width". "color" needs to be a hexadecimal color or a valid css color, "width" needs to be numeric.
- trace_colors
Character vector. Trace colors in order of usage. Needs to be hexadecimal colors or valid css colors. You should provide enough colors for most use cases, although
roboplotr
is able to extrapolate.- xaxis_ceiling
Character. Default rounding for yaxis limit. One of "default", "days", "months", "weeks", "quarters", "years" or "guess".
- zeroline
Function. Control the appearance of zeroline when set using
roboplot()
parameterzeroline
. Useset_zeroline()
.- zoom
Function. Control zooming defaults. Use
set_zoom()
.- verbose
Character. Will roboplotr display all messages, alerts and warnings, or warnings only? Must be one of "All", "Alert", or "Warning".
- shinyapp
Logical. Makes fonts, css and javascript available for shiny apps.
- reset
Logical or character. Resets options to roboplotr defaults or to defaults you have previously specified with
set_roboplot_options(name)
.- .defaults
Deprecated. Use
name
instead.
Examples
# Control global options for `roboplotr`. Some of these you can set
# also in `roboplot()`, `robotable()` or `robomap()`, some are available only
# globally.
# Basic plot frame colors for ticks, grid and border, background, height, and
# caption controls work like this:
d <- energiantuonti |>
dplyr::filter(Alue %in% c("USA","Norja"), Suunta == "Tuonti")
set_roboplot_options(
border = set_border(xcolor = "#eed5d2", ycolor = "#8b7d7b"),
caption_template = "Lähde: {text}.",
grid = set_grid(xcolor = "#9aff9a", ycolor = "cornsilk"),
background_color = "ghostwhite",
height = 700,
)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus")
# When testing different options, you can use 'reset' to reset default values.
set_roboplot_options(reset = TRUE)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus")
# You can also name your options for later use. Set some options and reset them:
set_roboplot_options(background_color = "whitesmoke", name = "smoke_background")
set_roboplot_options(reset = TRUE)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus")
# You can now reset to the named options:
set_roboplot_options(reset = "smoke_background")
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus")
# You can also tell `roboplot()` to use a specified option set without changing
# them for all plots.
set_roboplot_options(reset = TRUE)
d |> roboplot(Alue,
"Energian tuonti",
"Milj €",
"Tilastokeskus",
roboplot_options = "smoke_background")
# You can set the displayed lower right logo by 'logo_file'. Logo file needs
# the filepath to the logo used. The logo will be automatically scaled for
# `roboplotr` usage. If the logo is not the Robonomist logo, one will
# be automatically added to modebar (or you can add it manually as
# "robonomist").
# Control modebar.
set_roboplot_options(
logo_file = system.file("images", "robonomist.png", package = "roboplotr"),
modebar = set_modebar(
buttons = c(
"home",
"closest",
"compare",
"zoomin",
"zoomout",
"img_w",
"img_n",
"img_s",
"data_dl"
)
)
)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus")
# Files downloaded through plotly modebar require separate layout
# specifications which `roboplot()` automatically takes care of. Plot
# dimensions and font sizes might require extra specifications. Set these
# globally with `img_wide`, `img_narrow`, and / or `img_small` using
# `set_imgdl_layout()`.
set_roboplot_options(imgdl_wide = set_imgdl_layout(width = 1600))
# Captions are partly controlled by `caption`, while you will probably
# want to provide the actual content in `roboplot()`.
set_roboplot_options(
caption_template = "Lähteenä: {text}."
)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus")
# Trace appearance controls can be set globally.
set_roboplot_options(
dashtypes = c("longdash", "dashdot", "longdashdot", "solid", "dash", "dot"),
linewidth = 4,
markers = set_markers(symbol = "diamond", size = 12),
patterns = c("x","-","|","+",".","","/","\\"),
trace_colors = c("#027f93", "#153a42", "#f78b04"),
xaxis_ceiling = "guess"
)
d <- energiantuonti |> dplyr::filter(Alue %in% c("USA","Norja"))
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus", pattern = Suunta)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus",
plot_type = "bar",
pattern = Suunta)
d |> roboplot(Alue, "Energian tuonti", "Milj €", "Tilastokeskus",
plot_mode = "scatter+line",
pattern = Suunta)
set_roboplot_options(reset = TRUE)
# When used inside shiny apps, run `set_roboplot_options()` in app ui head with
# `shinyapp` = TRUE.
if (FALSE) { # \dontrun{
ui <- bs4Dash::dashboardPage(
bs4Dash::dashboardHeader(title = "Basic dashboard",
set_roboplot_options(shinyapp = TRUE)
),
bs4Dash::dashboardSidebar(),
bs4Dash::dashboardBody(
# Boxes need to be put in a row (or column)
shiny::fluidRow(
bs4Dash::box(plotly::plotlyOutput("plot1", height = 550)),
bs4Dash::box(plotly::plotlyOutput("plot2", height = 500))
)
)
)
server <- function(input, output) {
output$plot1 <- plotly::renderPlotly({
roboplot(
dplyr::filter(energiantuonti, Suunta == "Tuonti", Alue == "USA"),
Alue, "Energian tuonti Yhdysvalloista",
"Milj. €",
"Tilastokeskus")
})
output$plot2 <- plotly::renderPlotly({
roboplot(
dplyr::filter(energiantuonti, Suunta == "Vienti", Alue == "USA"),
Alue, "Energian vienti Yhdysvaltoihin",
"Milj. €",
"Tilastokeskus",
height = 500)
})
}
shiny::shinyApp(ui, server)
} # }