Plot a Spectra Object Interactively
This function uses the d3.js JavaScript library by Mike Bostock to plot a Spectra
object interactively. This is most useful for data exploration. For high
quality plots, consider plotSpectra
.
plotSpectraJS(spectra, which = NULL, browser = NULL, minify = TRUE)
spectra |
An object of S3 class |
which |
Integer. If not |
browser |
Character. Something that will make sense to your OS. Only
necessary if you want to override your system specified browser as
understood by |
minify |
Logical. Shall the JavaScript be minified? This improves
performance. However, it requires package |
The spectral data are incorporated into the web page. Keep in mind that very large
data sets, like NMR spectra with 32K points, will bog down the browser.
In these cases, you may need to limit the number of samples in passed to this function.
See removeSample
or use argument which
.
None; side effect is an interactive web page. The temporary directory containing the files that drive the web page is written to the console in case you wish to use those files. This directory is deleted when you quit R. If you wish to read the file, don't minify the code, it will be unreadable.
The browser is called by
browseURL
, which
in turn uses options("browser")
. Exactly how this is handled
is OS dependent.
If browser is NULL
, you are using RStudio, and a
viewer is specified, this will be called. You can stop this by with
options(viewer = NULL)
.
On a Mac, the default browser is called
by /bin/sh/open
which in turn looks at which browser you have set in the system settings. You can
override your default with
browser = "/usr/bin/open -a 'Google Chrome'"
for example.
You can check the performance of your browser at peacekeeper.futuremark.com The most relevant score is the rendering category.
Bryan A. Hanson, DePauw University.
plotSpectra
for non-interactive plotting. Details
about d3.js
are at https://d3js.org. Additional documentation at
https://bryanhanson.github.io/ChemoSpec/
if (interactive()) { require("jsonlite") require("js") data(metMUD2) plotSpectraJS(metMUD2) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.