From 94f2e69c03c974862c0b67ba267aadea0a144f0f Mon Sep 17 00:00:00 2001 From: Stathis Gennatas Date: Tue, 28 Apr 2026 05:23:30 -0700 Subject: [PATCH 1/2] => xlab/ylab & position in the middle --- r/R/draw_spectrogram.R | 18 ++++++++++-------- r/man/draw_spectrogram.Rd | 8 ++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/r/R/draw_spectrogram.R b/r/R/draw_spectrogram.R index b36355a..4faa9cb 100644 --- a/r/R/draw_spectrogram.R +++ b/r/R/draw_spectrogram.R @@ -200,9 +200,9 @@ #' @param colorbar_title Optional Character: Colorbar label. Default: `"dB"`, #' `"Power"`, or `"Amplitude"` derived from `db` and `power`. #' @param title Optional Character: Chart title. -#' @param x_lab Optional Character: X-axis label. Default: `"Time (s)"` or +#' @param xlab Optional Character: X-axis label. Default: `"Time (s)"` or #' `"Time (ms)"` depending on `time_unit`. -#' @param y_lab Optional Character: Y-axis label. Default: `"Frequency (Hz)"` +#' @param ylab Optional Character: Y-axis label. Default: `"Frequency (Hz)"` #' or `"Frequency (kHz)"` depending on `freq_unit`. #' @param theme Optional [Theme], list, or `NA`: Theme override passed to #' [draw()]. @@ -243,8 +243,8 @@ draw_spectrogram <- function( show_colorbar = TRUE, colorbar_title = NULL, title = NULL, - x_lab = NULL, - y_lab = NULL, + xlab = NULL, + ylab = NULL, theme = NULL, margins = DEFAULT_MARGINS, width = NULL, @@ -574,8 +574,8 @@ draw_spectrogram <- function( freq_digits <- if (freq_unit == "kHz") 3L else 1L val_digits <- if (db) 1L else 3L - x_lab <- x_lab %||% paste0("Time (", time_unit, ")") - y_lab <- y_lab %||% paste0("Frequency (", freq_unit, ")") + xlab <- xlab %||% paste0("Time (", time_unit, ")") + ylab <- ylab %||% paste0("Frequency (", freq_unit, ")") colorbar_title <- colorbar_title %||% if (db) { "dB" @@ -640,7 +640,8 @@ draw_spectrogram <- function( x_axis = Axis( type = "category", data = as.list(time_fmt), - name = x_lab, + name = xlab, + name_location = if (!is.null(xlab)) "middle" else NULL, boundary_gap = TRUE, split_area = SplitArea(show = FALSE), axis_line = AxisLine(show = FALSE) @@ -648,7 +649,8 @@ draw_spectrogram <- function( y_axis = Axis( type = "category", data = as.list(freq_fmt), - name = y_lab, + name = ylab, + name_location = if (!is.null(xlab)) "middle" else NULL, boundary_gap = TRUE, split_area = SplitArea(show = FALSE), axis_line = AxisLine(show = FALSE) diff --git a/r/man/draw_spectrogram.Rd b/r/man/draw_spectrogram.Rd index c7f2efc..cf4af16 100644 --- a/r/man/draw_spectrogram.Rd +++ b/r/man/draw_spectrogram.Rd @@ -27,8 +27,8 @@ draw_spectrogram( show_colorbar = TRUE, colorbar_title = NULL, title = NULL, - x_lab = NULL, - y_lab = NULL, + xlab = NULL, + ylab = NULL, theme = NULL, margins = DEFAULT_MARGINS, width = NULL, @@ -110,10 +110,10 @@ transformations (dB clipping, unit conversion). Defaults to the data range.} \item{title}{Optional Character: Chart title.} -\item{x_lab}{Optional Character: X-axis label. Default: \code{"Time (s)"} or +\item{xlab}{Optional Character: X-axis label. Default: \code{"Time (s)"} or \code{"Time (ms)"} depending on \code{time_unit}.} -\item{y_lab}{Optional Character: Y-axis label. Default: \code{"Frequency (Hz)"} +\item{ylab}{Optional Character: Y-axis label. Default: \code{"Frequency (Hz)"} or \code{"Frequency (kHz)"} depending on \code{freq_unit}.} \item{theme}{Optional \link{Theme}, list, or \code{NA}: Theme override passed to From e8214b4bd7a15361d74adcc2ce0930d84bf7920a Mon Sep 17 00:00:00 2001 From: Stathis Gennatas Date: Tue, 28 Apr 2026 05:28:20 -0700 Subject: [PATCH 2/2] up --- r/R/draw_spectrogram.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/R/draw_spectrogram.R b/r/R/draw_spectrogram.R index 4faa9cb..9520c4a 100644 --- a/r/R/draw_spectrogram.R +++ b/r/R/draw_spectrogram.R @@ -650,7 +650,7 @@ draw_spectrogram <- function( type = "category", data = as.list(freq_fmt), name = ylab, - name_location = if (!is.null(xlab)) "middle" else NULL, + name_location = if (!is.null(ylab)) "middle" else NULL, boundary_gap = TRUE, split_area = SplitArea(show = FALSE), axis_line = AxisLine(show = FALSE)