Skip to contents

Package overview

ggspectra ggspectra-package
ggspectra: Extensions to 'ggplot2' for Radiation Spectra

Plot basics

Function ggplot() is a generic method defined in package ‘ggplot2’, especialisations defined in package ‘ggspectra’ provide default aes() for spectral classes.

Layer: Geoms

Geoms, short for geometric objects, describe the type of plot you will produce.

geom_spct()
Spectral data plots.

Layer: Statistics

It is often useful to summarize spectral data before plotting, and that is what these transformations do.

stat_color()
Calculate colours from wavelength.
stat_find_qtys()
Find quantity value for target wavelength value.
stat_find_wls()
Find wavelength for target quantity value.
stat_peaks() stat_valleys()
Find peaks and valleys.
stat_label_peaks() stat_label_valleys()
Label peaks and valleys.
stat_spikes()
Find spikes
stat_wb_box()
Draw colour boxes for wavebands
stat_wb_hbar()
Integrate ranges under curve.
stat_wb_column()
Integrate ranges under curve.
stat_wb_contribution()
Integrate ranges under spectral curve.
stat_wb_irrad() stat_wb_e_irrad() stat_wb_q_irrad()
Integrate irradiance for wavebands.
stat_wb_label()
Label ranges under spectral curve.
stat_wb_mean()
Integrate ranges under curve.
stat_wb_relative()
Integrate ranges under spectral curve.
stat_wb_sirrad() stat_wb_e_sirrad() stat_wb_q_sirrad()
Integrate spectral irradiance for wavebands.
stat_wb_total()
Integrate ranges under spectral curve.
stat_wl_strip() wl_guide()
Calculate colours from wavelength.
stat_wl_summary()
Average area under curve for regions.

Scales

Scales control the mapping between data and aesthetics. The scales defined in package ‘ggspectra’ are continuous scales with defaults suitable for spectral data.

Automatic plot creation

Autoplot methods for spectra and a function for color-patch charts. They all return gg objects.

autoplot(<raw_spct>) autoplot(<raw_mspct>)
Plot one or more raw-detector-counts spectra.
autoplot(<calibration_spct>) autoplot(<calibration_mspct>)
Plot one or more irradiance-calibration spectra.
autoplot(<cps_spct>) autoplot(<cps_mspct>)
Plot one or more detector-counts-per-second spectra.
autoplot(<source_spct>) autoplot(<source_mspct>)
Plot one or more light-source spectra.
autoplot(<response_spct>) autoplot(<response_mspct>)
Plot one or more response spectra.
autoplot(<filter_spct>) autoplot(<filter_mspct>)
Plot one or more "filter" spectra.
autoplot(<reflector_spct>) autoplot(<reflector_mspct>)
Plot one or more reflector spectra.
autoplot(<object_spct>) autoplot(<object_mspct>)
Plot one or more "object" spectra.
autoplot(<generic_spct>) autoplot(<generic_mspct>)
Plot generic spectral data.
autoplot(<waveband>)
Create a complete ggplot for a waveband descriptor.
autotitle() ggtitle_spct()
Add title, subtitle and caption to a spectral plot
set_annotations_default() set_w.band_default()
Set defaults for autoplot annotations
color_chart()
Create a color checker chart

Helper functions

Formatters, International System of units, unit conversions.

black_or_white()
Chose black vs. white color based on weighted mean of RGB channels
exponent2prefix() exponent2factor() exponent2prefix_name() prefix_name2exponent() prefix2exponent() has_SI_prefix() nearest_SI_exponent()
SI unit prefixes
SI_pl_format() SI_plain()
Formatter for plain labels discounting for SI multipliers
SI_tg_format() SI_tagged()
Formatter for tagged labels using SI multipliers
w_number() w_frequency()
Deprecated functions
axis_labels_uk() axis_labels_uk_comma() axis_labels_none() axis_labels()
Default text for axis labels
w_length_label() w_number_label() w_frequency_label() w_energy_eV_label() w_energy_J_label()
Wave- axis labels
counts_label()
Raw-counts axis labels
cps_label()
Counts-per-second axis labels
Rfr_label() Rfr_specular_label()
Reflectance axis labels
A_label() A_internal_label() A_total_label()
Absorbance axis labels
Tfr_label() Tfr_internal_label() Tfr_total_label()
Transmittance axis labels
Afr_label() Rfr_total_label()
Absorptance axis labels
s.e.irrad_label() s.q.irrad_label()
Spectral irradiance axis labels
s.e.response_label() s.q.response_label() s.e.action_label() s.q.action_label()
spectral response and action axis labels
multipliers_label()
Calibration multipliers axis labels
multiplot()
Multiple plot function
plot(<generic_spct>) plot(<generic_mspct>) plot(<waveband>)
Deprecated plot methods