Learn R Programming

ggspectra (version 0.3.16)

set_annotations_default: Set defaults for plotting

Description

Set R options controlling default arguments for some formal parameters in methods and functions from package 'ggspectra'.

Usage

set_annotations_default(annotations = NULL)

set_w.band_default(w.band = NULL)

set_markup_format_default(markup.format = NULL)

set_plot_range_default(range = NULL)

set_pc_out_default(pc.out = TRUE)

set_axis_symbols_default(axis.symbols = TRUE)

Value

Previous value of the option, returned invisibly. This is a named list of length one as returned by options, that can be passed unchanged as argument to R function options or in a new call to the same function that returned it.

Arguments

annotations

a character vector. For details please see sections Plot Annotations and Title Annotations.

w.band

a single waveband object or a list of waveband objects.

markup.format

character string, "R", "R.expression", "r.character", or "LaTeX".

range

an R object on which range() returns a vector of length 2, with minimum and maximum wavelengths (nm).

pc.out

logical, if TRUE use percent instead of fraction of one for normalized spectral data.

axis.symbols

logical If TRUE symbols of the quantities are added to the default name.

Plot Annotations

The recognized annotation names are: "summaries", "peaks", "peak.labels", "valleys", "valley.labels", "wls", "wls.labels", "colour.guide", "color.guide", "boxes", "segments", "labels". In addition, "+" is interpreted as a request to add to the already present default annotations, "-" as request to remove annotations and "=" or missing"+" and "-" as a request to reset annotations to those requested. If used, "+", "-" or "=" must be the first member of a character vector, and followed by one or more of the names given above. To simultaneously add and remove annotations one can pass a list containing character vectors each assembled as described. The vectors are applied in the order they appear in the list. To disable all annotations pass "" or c("=", "") as argument. Adding a variation of an annotation already present, replaces the existing one automatically: e.g., adding "peak.labels" replaces"peaks" if present.

The annotation layers are added to the plot using statistics defined in 'ggspectra': stat_peaks, stat_valleys, stat_label_peaks, stat_label_valleys, stat_find_wls, stat_spikes, stat_wb_total, stat_wb_mean, stat_wb_irrad, stat_wb_sirrad, stat_wb_contribution, stat_wb_relative, and stat_wl_strip. However, only some of their parameters can be passed arguments through autoplot methods. In some cases the defaults used by autoplot methods are not the defaults of the statistics.

Title Annotations

metadata retrieved from object object is paased to ggplot2::ggtitle() as arguments for title, subtitle and caption. The specification for the title is passed as argument to annotations, and consists in the keyword title with optional modifiers selecting the kind of metatdata to use, separated by colons. Up to three keywords separated by colons are accepted, and correspond to title, subtitle and caption. The recognized keywords are: "objt", "class", "what", "when", "where", "how", "inst.name", "inst.sn", "comment" and "none" are recognized as modifiers to "title"; "none" is a placeholder. Default is "title:objt" or no title depending on the context.

Details

The values accepted, syntax used and behaviour are the same as when passing arguments to formal parameters in function and methods calls, except that NULL as argument clears the R option. To restore the previous state of an option, save the value returned and pass it as argument in a later call to the same function.

Changing the defaults with options, instead of affecting a single function call (e.g., affecting a single plot or layer in a plot), changes the default used for all subsequent function calls calls when when no argument is passed explicitly. This makes it possible to easily change in one place in a script the appearance of all/multiple plots. Using these functions functions instead of options to set the defaults adds a validation step that protects from errors triggered in subsequent function calls.

R option photobiology.plot.annotations controls the default for formal parameter annotations in autoplot methods and in function decoration.

R option photobiology.plot.bands controls the default for formal parameter w.band in autoplot methods and in function decoration.

R option photobiology.math controls the default for formal parameter markup.format or format in different axis label and scale functions.

R option ggspectra.wlrange controls the default for formal parameter range in autoplot methods.

R option ggspectra.pc.out controls the default for formal parameter pc.out in autoplot methods that have this formal parameter.

R option ggspectra.axis.symbols controls the default for formal parameter axis.symbols in different axis label and scale functions.

See Also

Additional argument defaults are controlled by options also used in package 'photobiology'. See energy_as_default, using_Tfr and options.