Skip to contents

Draw interactive spectrograms using plotly

Usage

draw_spectrogram(
  x,
  y,
  z,
  colorgrad_n = 101,
  colors = NULL,
  xlab = "Time",
  ylab = "Frequency",
  zlab = "Power",
  hover_xlab = xlab,
  hover_ylab = ylab,
  hover_zlab = zlab,
  zmin = NULL,
  zmax = NULL,
  zauto = TRUE,
  hoverlabel_align = "right",
  colorscale = "Jet",
  colorbar_y = 0.5,
  colorbar_yanchor = "middle",
  colorbar_xpad = 0,
  colorbar_ypad = 0,
  colorbar_len = 0.75,
  colorbar_title_side = "bottom",
  showgrid = FALSE,
  space = "rgb",
  lo = "#18A3AC",
  lomid = NULL,
  mid = NULL,
  midhi = NULL,
  hi = "#F48024",
  grid_gap = 0,
  limits = NULL,
  main = NULL,
  key_title = NULL,
  showticklabels = NULL,
  theme = rtemis_theme,
  font_size = NULL,
  padding = 0,
  displayModeBar = TRUE,
  modeBar_file_format = "svg",
  filename = NULL,
  file_width = 500,
  file_height = 500,
  file_scale = 1,
  ...
)

Arguments

x

Numeric: Time.

y

Numeric: Frequency.

z

Numeric: Power.

colorgrad_n

Integer: Number of colors in the gradient.

colors

Character: Custom colors for the gradient.

xlab

Character: x-axis label.

ylab

Character: y-axis label.

zlab

Character: z-axis label.

hover_xlab

Character: x-axis label for hover.

hover_ylab

Character: y-axis label for hover.

hover_zlab

Character: z-axis label for hover.

zmin

Numeric: Minimum value for color scale.

zmax

Numeric: Maximum value for color scale.

zauto

Logical: If TRUE, automatically set zmin and zmax.

hoverlabel_align

Character: Alignment of hover labels.

colorscale

Character: Color scale.

colorbar_y

Numeric: Y position of colorbar.

colorbar_yanchor

Character: Y anchor of colorbar.

colorbar_xpad

Numeric: X padding of colorbar.

colorbar_ypad

Numeric: Y padding of colorbar.

colorbar_len

Numeric: Length of colorbar.

colorbar_title_side

Character: Side of colorbar title.

showgrid

Logical: If TRUE, show grid.

space

Character: Color space for gradient.

lo

Character: Low color for gradient.

lomid

Character: Low-mid color for gradient.

mid

Character: Mid color for gradient.

midhi

Character: Mid-high color for gradient.

hi

Character: High color for gradient.

grid_gap

Integer: Space between cells.

limits

Numeric, length 2: Determine color range. Default = NULL, which automatically centers values around 0.

main

Character: Main title.

key_title

Character: Title of the key.

showticklabels

Logical: If TRUE, show tick labels.

theme

List: Theme settings.

font_size

Numeric: Font size.

padding

Numeric: Padding between cells.

displayModeBar

Logical: If TRUE, display the plotly mode bar.

modeBar_file_format

Character: File format for image exports from the mode bar.

filename

Character: Filename to save the plot. Default is NULL.

file_width

Numeric: Width of exported image.

file_height

Numeric: Height of exported image.

file_scale

Numeric: Scale of exported image.

...

Additional arguments to be passed to heatmaply::heatmaply.

Value

A plotly object.

Details

To set custom colors, use a minimum of lo and hi, optionally also lomid, mid, midhi colors and set colorscale = NULL.

Author

EDG