marginals: Add a marginal plot (histogram/density on axes)

View source: R/layout.R

marginalsR Documentation

Add a marginal plot (histogram/density on axes)

Description

Draws the distribution of the x and y variables along the edges of the plot, as a histogram, density curve or boxplot.

Usage

marginals(spec, x = "histogram", y = "histogram", size = 0.15)

Arguments

spec

A glyph_spec

x

Marginal type for x-axis: "histogram", "density", "boxplot", NULL

y

Marginal type for y-axis: "histogram", "density", "boxplot", NULL

size

Proportion of plot area for marginals (0.0 to 0.4)

Value

Modified glyph_spec

Examples

glyph(mtcars, x = wt, y = mpg) |>
  mark_point(color = cyl) |>
  marginals(x = "histogram", y = "density")

glyph documentation built on Oct. 21, 2026, 5:12 p.m.