Skip to contents

The seam between convenient input and a complete, validated object. Every argument is optional, which is what lets the published schema require nothing.

Usage

setup_SpectrogramConfig(
  sample_rate = NULL,
  n_fft = 256L,
  window = "hanning",
  overlap = NULL,
  power = TRUE,
  db = TRUE,
  db_range = 80,
  freq_scale = "linear",
  freq_range = NULL,
  time_range = NULL,
  freq_unit = "Hz",
  time_unit = "s",
  colormap = "magma",
  colormap_reverse = FALSE,
  n_colors = 256L,
  zlim = NULL,
  show_colorbar = TRUE,
  colorbar_title = NULL,
  xlab = NULL,
  ylab = NULL,
  title = NULL,
  margin_top = NULL,
  margin_right = NULL,
  margin_bottom = NULL,
  margin_left = NULL,
  dat_path = NULL,
  origin = NULL,
  writer = NULL,
  legend_position = "right",
  legend_placement = "outside"
)

Arguments

sample_rate

Optional Numeric [0, Inf): Signal sample rate in Hz.

n_fft

Integer [2, Inf): FFT window length.

window

Character: Window function.

overlap

Optional Numeric [0, 1): Fractional window overlap.

power

Logical: Use the power spectrum rather than magnitude.

db

Logical: Convert to decibels.

db_range

Numeric [0, Inf): Dynamic range in dB below the peak.

freq_scale

Character {"linear", "log", "mel"}: Frequency axis scale.

freq_range, time_range

Optional Numeric: Axis limits, length 2.

freq_unit, time_unit

Character: Axis units, for the labels.

colormap

Character: Continuous color scheme, or two or more hex colors defining one.

colormap_reverse

Logical: Reverse the color scheme.

n_colors

Integer [2, Inf): Number of discrete colors.

zlim

Optional Numeric: Color-scale limits, length 2.

show_colorbar

Logical: Draw the color bar.

colorbar_title

Optional Character: Color bar title.

xlab, ylab

Optional Character: Axis labels.

title

Optional Character: Chart title. Declared here because it is the one property every chart type has; palette is not (four take a colormap instead), and axis labels and margins are cartesian-only.

margin_top, margin_right, margin_bottom, margin_left

Optional Integer [0, Inf): Override the auto-computed margins, per side.

dat_path

Optional Character: Path to the data, read at draw time. The serializable alternative to passing data to draw().

origin

Optional Named character: Where each value came from. Normally computed from which arguments were supplied; pass it only when restoring a config that already carries provenance.

writer

Optional Named character: Which interface wrote the config.

legend_position

Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.

legend_placement

Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.

Value

SpectrogramConfig object.

Author

EDG

Examples

m <- matrix(abs(rnorm(64 * 20)) + 1, nrow = 64)
draw(setup_SpectrogramConfig(), data = m)