Learn R Programming

ggspectra (version 0.3.6)

autotitle: Add title, subtitle and caption to a spectral plot

Description

Add a title, subtitle and caption to a spectral plot based on automatically extracted metadata stored from an spectral object.

Usage

autotitle(
  object,
  object.label = deparse(substitute(object)),
  annotations = "title",
  time.format = "",
  tz = lubridate::tz(getWhenMeasured(object)),
  default.title = "title:objt"
)

ggtitle_spct( object, object.label = deparse(substitute(object)), annotations = "title", time.format = "", tz = lubridate::tz(getWhenMeasured(object)), default.title = "title:objt" )

Arguments

object

generic_spct The spectral object plotted.

object.label

character The name of the object being plotted.

annotations

character vector Annotations as described for plot() methods, values unrelated to title are ignored.

time.format

character Format as accepted by strptime.

tz

character time zone used in labels.

default.title

character vector The default used for annotations = "title".

Value

The return value of ggplot2::labs().

Details

autotitle() retrieves from object object metadata and passes it to ggplot2::ggtitle() as arguments for title, subtitle and caption. The specification for the tittle 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.

Examples

Run this code
# NOT RUN {
p <- ggplot(sun.spct) +
  geom_line()

p + autotitle(sun.spct)
p + autotitle(sun.spct, annotations = "title:what")
p + autotitle(sun.spct, annotations = "title:where:when")
p + autotitle(sun.spct, annotations = "title:none:none:comment")

# }

Run the code above in your browser using DataLab