| draw_spectrum | R Documentation |
Draws a single spectrum. Internally used by plot_spectrum(), which is
usually the recommended way to plot spectra. For usage examples see
test/testthat/test-draw_spectrum.R.
draw_spectrum(
obj,
foc_rgn = NULL,
foc_frac = NULL,
foc_only = TRUE,
add = FALSE,
fig_rgn = NULL,
main = NULL,
show = TRUE,
show_d2 = FALSE,
truepar = NULL,
mar = c(4.1, 5.1, 1.1, 1.1),
sf_vert = "auto",
si_line = list(),
sm_line = list(),
sp_line = list(),
d2_line = list(),
al_line = list(),
lc_lines = list(),
tp_lines = list(),
al_lines = list(),
cent_pts = list(),
bord_pts = list(),
norm_pts = list(),
bg_rect = list(),
foc_rect = list(),
lc_rects = list(),
tp_rects = list(),
bt_axis = list(),
lt_axis = list(),
tp_axis = list(),
rt_axis = list(),
bt_text = list(),
lt_text = list(),
tp_text = list(),
rt_text = list(),
tp_verts = list(),
lc_verts = list(),
al_verts = list(),
ze_hline = list(),
al_arrows = list(),
lgd = list()
)
obj |
An object of type |
foc_rgn |
Numeric vector specifying the start and end of focus region in ppm. |
foc_frac |
Numeric vector specifying the start and end of focus region as fraction of the full spectrum width. |
foc_only |
Logical. If TRUE, only the focused region is drawn. If FALSE, the full spectrum is drawn. |
add |
If TRUE, draw into the currently open figure. If FALSE, start a new figure. |
fig_rgn |
Drawing region in normalized device coordinates as vector of the form |
main |
Main title of the plot. Drawn via |
show |
Logical. If FALSE, the function returns without doing anything. |
show_d2 |
Logical. If TRUE, the second derivative of the spectrum is drawn. Setting this to TRUE changes most of the defaults for the drawing, e.g. by disabling the drawing of anything related to signal intensities and by changing the y-axis label to "Second Derivative". |
truepar |
Data frame with columns x0, A and lambda containing the true lorentzian that
were used to simulate the spectrum. Required if any |
mar |
Number of lines below/left-of/above/right-of plot region. |
sf_vert |
Scale factor for vertical lines corresponding to
|
si_line, sm_line, sp_line, al_line, d2_line, lc_lines, tp_lines, al_lines |
List of parameters passed to |
cent_pts, bord_pts, norm_pts |
List of parameters passed to |
bg_rect, lc_rects, foc_rect, tp_rects |
List of parameters passed to |
bt_axis, lt_axis, tp_axis, rt_axis |
List of parameters used to overwrite the default values passed to
|
bt_text, lt_text, tp_text, rt_text |
List of parameters used to overwrite the default values passed to |
lc_verts, tp_verts, al_verts |
List of parameters passed to |
ze_hline |
List of parameters passed to |
al_arrows |
List of parameters passed to |
lgd |
List of parameters passed to |
Parameters bt_axis, lt_axis, tp_axis and rt_axis all support option
n and digits, where n = 5 means "Draw 5 tickmarks over the full axis
range" and digits = 3 means "round the label shown beside each tickmark to
3 digits". If n or digits is omitted, a suitable value is chosen
automatically. Providing a vector of digits causes each digit to be tried
until a digit is encountered that results in n unique labels. Example:
Assume we have n = 4 and the corresponding calculated tickmark positions
are: 1.02421, 1.02542, 1.02663 and 1.02784. If we provide digits = 1:5, the
following representations are tried:
| digit | label 1 | label 2 | label 3 | label 4 |
| 1 | 1.0 | 1.0 | 1.0 | 1.0 |
| 2 | 1.02 | 1.03 | 1.03 | 1.03 |
| 3 | 1.024 | 1.025 | 1.027 | 1.028 |
| 4 | 1.0242 | 1.0254 | 1.0266 | 1.0278 |
| 5 | 1.02421 | 1.02542 | 1.02663 | 1.02784 |
In the above example the process would stop at digit = 3, because at this
point we have n = 4 unique labels (1.024, 1.025, 1.027 and 1.028).
NULL. Called for side effect of plotting.
2024-2025 Tobias Schmidt: initial version.
decon <- deconvolute(sim[[1]], sfr = c(3.55, 3.35))
draw_spectrum(obj = decon)
draw_spectrum(obj = decon, lgd = list(x = "top", bg = NA))
draw_spectrum(obj = decon, foc_rgn = c(3.45, 3.37))
draw_spectrum(obj = decon, add = FALSE, lgd = FALSE,
fig = c(.2, .8, .2, .4), mar = c( 0, 0, 0, 0))
draw_spectrum(obj = decon, add = TRUE, lgd = FALSE,
fig = c(0.2, 0.8, 0.6, 0.8), mar = c(0, 0, 0, 0))
draw_spectrum(obj = decon, lc_lines = NULL, lc_rects = NULL, foc_only = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.