Draw a Density Plot
draw_density.RdKernel density estimation plot from numeric data, with optional grouping
for multiple traces. A list input creates one density trace per vector when
ungrouped, or one trace per variable/group combination when group is
supplied.
Usage
draw_density(
x,
group = NULL,
n = 512,
bw = "nrd0",
na.rm = TRUE,
xlab = NULL,
ylab = NULL,
title = NULL,
theme = NULL,
margins = NULL,
width = NULL,
height = NULL,
verbosity = 1L,
filename = NULL
)Arguments
- x
Numeric or list: Values used for density estimation. An ungrouped list creates one density trace per element; with
group, each list element is split by group into separate traces.- group
Optional Vector: Grouping variable for multiple density traces.
- n
Numeric
[1, Inf): Number of equally spaced points for density estimation.- bw
Character or Numeric: Bandwidth passed to
stats::density().- na.rm
Logical: Whether to remove
NAvalues before computing densities.- xlab
Optional Character: X-axis title.
- ylab
Optional Character: Y-axis title.
- title
Optional Character: Chart title.
- theme
Optional Theme: Theme override.
- margins
Optional Named numeric vector or named list: Plot margins in pixels (or percentage strings) for any of
"top","right","bottom","left". Unspecified sides keep echarts' default auto-sizing. Seedraw_line()for details.- width
Optional Character or Numeric: Widget width.
- height
Optional Character or Numeric: Widget height.
- verbosity
Integer
[0, Inf): Verbosity level for removed-NAmessages.- filename
Optional Character: If provided, save the widget to this file via
save_drawing().