Plots cycle data from an ir_aggregate_isofiles() result or a plain data
frame. The data is prepared with ir_generate_cycles_tibble() (which, for an
ir_aggregated_data object, inner-joins the $cycles dataset with
$metadata). The plot data must contain species, cycle, type, mass,
and an intensity.* column — an error is thrown if any are missing. A trace
identifier ("<species>: <mass>") is always regenerated and the plotted
value together with a data_type label ("intensity [UNITS]", or
"ratios" for ratio rows) are added.
Usage
ir_plot_dual_inlet(
dataset,
species = NULL,
mass = NULL,
ratio = NULL,
facet = NULL,
data_type_as_facet = auto(),
scales = "free",
nrow = NULL,
ncol = 1,
color = trace,
shape = type,
linetype = NULL,
color_values = palette.colors(),
drop_unused_levels = FALSE,
scientific = FALSE,
cycle_window = NULL,
n_y_breaks = 5,
...
)Arguments
- dataset
an
ir_aggregated_dataobject fromir_aggregate_isofiles()or a plain data frame withspecies,cycle,type,mass, and anintensity.*column- species
optional vector to filter the displayed data to specific species (e.g.
"CO2"orc("N2", "CO2")); defaultNULLshows all species.- mass
which masses to include as intensity traces:
NULL(default) shows all masses, a vector (e.g.44orc(44, 45)) shows specific masses, and a zero-length vector (numeric(0)/character(0)) shows none. Note thatc()isNULLin R (i.e. all masses).- ratio
which ratios to additionally include (computed with
ir_calculate_ratios()):NULL(default) shows all available ratios, a character vector of ratio names (e.g.c("45/44", "46/44")) shows specific ones, andcharacter(0)shows none. Requesting specific ratio names when ratios have not been calculated is an error pointing toir_calculate_ratios()(withratio = NULLand no ratios present, none are simply added). Ratio rows are plotted on the samevalueaxis withdata_type = "ratios"; the defaultfacet = data_type(with free scales) separates them from the intensities.- facet
column or expression to facet by (default:
NULL, no extra faceting). Whendata_typeis used as a facet row (seedata_type_as_facet), a singlefacetvariable becomes the facet_grid column (data_type ~ facet) and aNULLfacet givesdata_type ~ .. Otherwise a plain column or expression (e.g.file_nameorpaste(species, mass)) is faceted withggplot2::facet_wrap(), and a two-sided formula (e.g.species ~ mass) is faceted withggplot2::facet_grid(). Set toNULLto suppress faceting.- data_type_as_facet
whether the
data_typecolumn (intensities vs ratios) is used as theggplot2::facet_grid()row variable:auto()(default) uses it only when more than one data type is present;TRUEalways uses it;FALSEnever does. When used, the y axis label is dropped (the facet strip provides it) and the facet becomesdata_type ~ .(aNULLfacet) ordata_type ~ facet(a single-variablefacet). It is ignored whenfacetis a two-sided formula (a warning is issued ifdata_type_as_facet = TRUEis combined with a formulafacet, since the two are mutually exclusive).- scales
whether facet scales should be
"free"(default),"fixed","free_x", or"free_y"; passed on toggplot2::facet_wrap()/ggplot2::facet_grid().- nrow, ncol
number of rows and columns of facet panels (
nrowdefaultNULLlets ggplot2 choose;ncoldefault1stacks the panels in a single column). Only applies whenfacetis a single variable or expression (faceted withggplot2::facet_wrap()); ignored whenfacetis a formula (faceted withggplot2::facet_grid()), with a warning if you set them explicitly.- color
column or expression for the colour aesthetic (default:
trace, the per-species/mass trace identifier, e.g."CO2: 44"). When colouring bytrace, traces that share the same species and (numerator) mass are given the same colour, so an intensity trace ("CO2: 45") and its ratio traces ("CO2: 45/44") match.- shape
column or expression for the point shape aesthetic (default:
type, distinguishing"standard"from"sample"cycles)- linetype
column or expression for the linetype aesthetic (default:
NULL, i.e. no linetype aesthetic)- color_values
named or unnamed character vector of colours passed to
ggplot2::scale_color_manual(), orNULLto use the ggplot2 default colour palette (default:palette.colors())- drop_unused_levels
whether to drop unused
tracefactor levels (e.g. traces that are absent after zooming to a window) from the colour scale and legend. DefaultFALSEkeeps every level so the colour mapping stays stable across subsets of the same dataset; set toTRUEto show only the levels actually present in the plotted data.- scientific
whether to format y axis labels in scientific notation (default:
FALSE)- cycle_window
optional numeric vector of length 2 giving the cycle axis display window
c(min, max)(must havemin < max). The data point just outside each edge of the window is retained so the clipped lines interpolate correctly across the window boundaries and y autoscales correctly at the edges;ggplot2::coord_cartesian()clips the display. A window that contains no data points of its own is allowed (the line is drawn between the bracketing points). DefaultNULLshows all cycles.- n_y_breaks
desired number of y axis tick marks (default:
5)- ...
additional arguments passed on to
ggplot2::facet_wrap()orggplot2::facet_grid()(e.g.labeller)
Value
a ggplot object with ir_default_theme() applied. To customize the
plot, add ggplot2 layers on top (e.g. + ggplot2::theme(...) or
+ ggplot2::labs(...)); attach ggplot2 with library(ggplot2) first.
