Plot the spectra and sum of fitted peaks from [fit_peaks()] using [PlotFTIR::plot_ftir()].
Tracez les spectres et la somme des pics ajustés à partir de [fit_peaks()] en utilisant [PlotFTIR::plot_ftir()].
Usage
plot_fit_ftir_peaks(
ftir,
fitted_peaks,
plot_components = FALSE,
lang = NA,
call = rlang::caller_env(),
...
)Arguments
- ftir
A data.frame in long format with a single FTIR spectra in columns `sample_id`, `wavenumber`, and `absorbance`.
Un data.frame au format long avec un seul spectre IRTF dans les colonnes `sample_id`, `wavenumber`, et `absorbance`.
- fitted_peaks
An object from [fit_peaks()]. Should match the provided sample in `ftir`.
Un objet de [fit_peaks()]. Doit correspondre à l'échantillon fourni dans `ftir`.
- plot_components
Boolean, whether to include the component peaks (see [plot_components()]).
Booléen, pour savoir s'il faut inclure les pics des composants (voir [plot_components()]).
- lang
An optional argument for language. If set to one of `fr`, `french`, `francais`, or `français` the axis and default plot and legend titles will change to french. If non-default legend or plot titles are provided they are used as-is. You can also provide `en`, `english` or `anglais`, or (the default) `NA` will use the default language from user options. To set a permanent default, set `options("PlotFTIR.lang" = "en")` or `options("PlotFTIR.lang" = "fr")` for English or French, respectively.
Un argument optionnel pour la langue. S'il vaut `Fr`, `French`, `Francais`, ou `Français`, l'axe et les titres par défaut de le tracé et du légende seront en français. Si des titres du légende ou de tracé autres que ceux par défaut sont fournis, ils seront utilisés tels quels. Vous pouvez aussi fournir `en`, `english` ou `anglais`, ou (le défaut) `NA` qui utilisera le langue par défaut des options de l'utilisateur. Pour définir une valeur par défaut permanente, mettez `options("PlotFTIR.lang" = "en")` ou `options("PlotFTIR.lang" = "fr")` pour l'anglais ou le français, respectivement.
- call
(`environment`) The caller environment for error messages. L'environnement de l'appelant pour les messages d'erreur.
- ...
Optional argument `fitted_sample_name` for naming the fitted peaks on the plot, or extra parameters to pass to [PlotFTIR::plot_ftir()].
Argument optionnel `fitted_sample_name` pour nommer les pics ajustés sur le graphique, ou des paramètres supplémentaires à passer à [PlotFTIR::plot_ftir()].
Examples
# Load the isopropanol sample spectrum from the PlotFTIR package
ftir_data <- PlotFTIR::sample_spectra[
PlotFTIR::sample_spectra$sample_id == "isopropanol",
]
# Choose a subset of the data (reducing run time)
ftir_data <- ftir_data[
ftir_data$wavenumber < 1500 & ftir_data$wavenumber > 1000,
]
if (requireNamespace("signal", quietly = TRUE)) {
# First, fit the peaks using the default 'voigt' method
fitted_voigt <- fit_peaks(ftir_data, method = "voigt")
}
# --- Example 1: Plot original spectrum and the overall fitted sum ---
if (FALSE) { # \dontrun{
plot_fit_ftir_peaks(ftir_data, fitted_voigt)
} # }
# --- Example 2: Plot original, overall fit, AND individual components ---
# This internally calls plot_components() with plot_fit = TRUE
if (FALSE) { # \dontrun{
plot_fit_ftir_peaks(ftir_data, fitted_voigt, plot_components = TRUE)
} # }
# --- Example 3: Plot original and fit with custom titles and name ---
if (FALSE) { # \dontrun{
plot_fit_ftir_peaks(
ftir_data,
fitted_voigt,
plot_title = c("Isopropanol Fit Comparison", "Original vs. Voigt Sum"),
legend_title = "Spectrum Source",
fitted_sample_name = "Total Voigt Fit"
)
} # }
# --- Example 4: Plot original and fit in French ---
if (FALSE) { # \dontrun{
plot_fit_ftir_peaks(ftir_data, fitted_voigt, lang = "fr")
} # }
