plotRidges: Plot ridges density plots for numeric matrix input

plotRidgesR Documentation

Plot ridges density plots for numeric matrix input

Description

Plot ridges density plots for numeric matrix input

Usage

plotRidges(
  x,
  xScale = c("none", "-log10", "log10"),
  xlab = NULL,
  ylab = NULL,
  title = ggplot2::waiver(),
  subtitle = ggplot2::waiver(),
  caption = ggplot2::waiver(),
  xlim = NULL,
  color_sub = NULL,
  rel_min_height = 0,
  bandwidth = NULL,
  adjust = 1,
  scale = 1,
  share_bandwidth = TRUE,
  ...
)

Arguments

x

matrix with numeric values, or a list of numeric vectors. In either case the data is converted to long-tall format before plotting.

xScale

character string indicating whether to transform the x-axis values:

  • "none": no transformation

  • "-log10": values are transformed with log10(x) and x-axis labels are adjusted accordingly.

  • "log10": values are transformed with log10(1 + x) except that negative values are transformed with -log10(1 - x). The x-axis labels are plotted to account for the log10(1 + x) offset.

xlab, ylab

character strings optionally used as x-axis and y-axis labels.

title, subtitle, caption

character string values optionally passed to the relevant downstream ggplot2 functions.

xlim

passed to ggplot2::xlim() to define the x-axis range.

color_sub

character vector named by colnames(x), or when x is a list, names(color_sub) should contain names(x), used to define specific colors for each ridge plot.

rel_min_height

numeric values passed to ggridges::geom_density_ridges2()

bandwidth

numeric value used to define the bandwidth density when share_bandwidth=TRUE which is default. The bandwidth affects the level of detail presented in each ridgeline, and when shared across ridgelines share_bandwidth=TRUE then each ridgeline will use the same consistent level of detail. In this case, it is passed to ggridges::geom_density_ridges2(). Note when bandwidth=NULL a default value is derived from the range of data to be plotted.

adjust

numeric used to adjust the default bandwidth only when bandwidth=NULL. It is intended as a convenient method to adjust the level of detail.

scale

numeric passed directly to ggridges::geom_density_ridges2().

share_bandwidth

logical indicating whether to supply ggridges::geom_density_ridges2() a specific bandwidth to use for all ridgelines. When share_bandwidth=FALSE then each ridgeline is presented using the default bandwidth in ggridges::geom_density_ridges2().

...

additional arguments are ignored.

Details

This function is a convenient wrapper for ggridges::geom_density_ridges2(), intended to be analogous to plotPolygonDensity() which differs by plotting each item in a separate plot panel using base graphics. This function plots each item as a ridgeline plot in the same plot window using ggplot2::ggplot().

See Also

Other jam plot functions: adjustAxisLabelMargins(), coordPresets(), decideMfrow(), drawLabels(), getPlotAspect(), groupedAxis(), imageByColors(), imageDefault(), minorLogTicksAxis(), nullPlot(), plotPolygonDensity(), plotSmoothScatter(), shadowText_options(), shadowText(), showColors(), smoothScatterJam(), sqrtAxis(), usrBox()

Examples

# multiple columns
set.seed(123);
xm <- do.call(cbind, lapply(1:4, function(i){rnorm(2000)}))
plotRidges(xm)

set.seed(123);
x <- rnorm(2000)
plotRidges(x)


jmw86069/jamba documentation built on Oct. 9, 2024, 10:52 a.m.