Package overview

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.

ggplot(<source_spct>) ggplot(<response_spct>) ggplot(<filter_spct>) ggplot(<reflector_spct>) ggplot(<cps_spct>) ggplot(<calibration_spct>) ggplot(<raw_spct>) ggplot(<object_spct>) ggplot(<generic_mspct>)

Create a new ggplot plot from spectral data.

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_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.

scale_x_wl_continuous()

Wavelength x-scale

scale_y_s.e.response_continuous() scale_y_s.q.response_continuous()

Spectral response y-scale

scale_y_s.e.irrad_continuous() scale_y_s.q.irrad_continuous() scale_y_s.q.irrad_log10() scale_y_s.e.irrad_log10()

Spectral irradiance y-scale

scale_y_A_internal_continuous() scale_y_A_total_continuous()

Absorbance y-scale

scale_y_Tfr_internal_continuous() scale_y_Tfr_total_continuous()

Transmittance y-scale

scale_y_Rfr_specular_continuous() scale_y_Rfr_total_continuous()

Reflectance y-scale

scale_y_cps_continuous()

Counts-per-second y-scale

scale_y_counts_continuous() scale_y_counts_tg_continuous()

Raw-counts y-scale

sec_axis_w_number() sec_axis_w_frequency()

Secondary axes for wavelengths

Automatic plot creation

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

autoplot(<raw_spct>)

Create a complete ggplot for raw detector-counts spectra.

autoplot(<calibration_spct>) autoplot(<calibration_mspct>)

Create a complete ggplot for an irradiation calibration spectrum.

autoplot(<cps_spct>)

Create a complete ggplot for detector-counts per second spectra.

autoplot(<source_spct>) autoplot(<source_mspct>)

Create a complete ggplot for a light-source spectrum.

autoplot(<response_spct>) autoplot(<response_mspct>)

Create a complete ggplot for a response spectrum.

autoplot(<filter_spct>) autoplot(<filter_mspct>)

Create a complete ggplot for a filter spectrum.

autoplot(<reflector_spct>) autoplot(<reflector_mspct>)

Create a complete ggplot for a reflector spectrum.

autoplot(<object_spct>) autoplot(<object_mspct>)

Create a complete ggplot for a object spectrum.

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()

Wavelength conversions

A_internal_label() A_total_label()

Absorbance axis labels

counts_label()

Raw-counts axis labels

cps_label()

Counts-per-second axis labels

Rfr_specular_label() Rfr_total_label()

Reflectance axis labels

Tfr_internal_label() Tfr_total_label()

Transmittance axis labels

s.e.irrad_label() s.q.irrad_label()

spectral irradiance axis labels

s.e.response_label() s.q.response_label()

spectral response axis labels

w_length_label() w_number_label() w_frequency_label()

Wave- axis labels

multiplot()

Multiple plot function