R: Add title to a spectral plot

ggtitle_spct {ggspectra} | R Documentation

## Add title to a spectral plot

### Description

Add a title to a spectral plot based on metadata stored in an spectral object.

### Usage

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

### Arguments

`x` | generic_spct The spectral object plotted.
`x.name` | 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"`.

### Details

`ggtitle_spct()` retrieves from object `x` metadata and passes it to `ggplot2::ggtitle()` as arguments for `title` and `subtitle`. 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. "objt", "class", "what", "when", "where", "inst.name", "inst.sn" and "none" are recognized as modifiers to "title".

### Value

The return value of `ggplot2::ggtitle()`.

### Examples

    library(ggplot2)
    library(photobiology)

    p <- ggplot(sun.spct) +
      geom_line()

    p + ggtitle_spct(sun.spct)
    p + ggtitle_spct(sun.spct, annotations = "title:where:when")

[Package ggspectra version 0.2.3 Index]