violin
A Gaussian kernel density estimate of a sample, mirrored about the line it stands on.
violinxxyargandplane

A violin draws a Gaussian kernel density estimate of the readings, mirrored about the line it stands on: wide where readings crowd and narrow where they thin, cut off square at the smallest and largest reading. It is the estimate a density draws as one curve.
It stands as a boxplot does — a lane on the number line, one coordinate and on: on a plane, or both coordinates with one axis ruled in names for a violin at every name — and is refused with both axes numeric, which leaves no line to stand on. A violin, a box and a scatter of the same readings at one place share one slot, so a narrow box sits inside its violin:
graph{
violin(x: #penguins.flipper; y: #penguins.species; colour: purple)
boxplot(x: #penguins.flipper; y: #penguins.species; band: 0.15; colour: teal)
}(
x axis label: flipper length (mm)
)Every violin is band of its slot wide at its own peak, so the shapes compare and the sample sizes do not. bandwidth is the standard deviation of the kernel, in the readings' units; left out, each sample takes Silverman's rule, as a density does. A written bandwidth must be positive (canvas/violin-bandwidth); a parameter driven to zero draws nothing.
#Attributes
bandwidthcanvas/violin-bandwidth); a parameter driven to zero draws nothing.colourcolour: grey, teal. Grouped by a column of names, it can also be applied to that column, so each violin takes its own name's colour whatever order the violins stand in: colour: #polls.party -> (DEM: blue; REP: red; otherwise: grey).colour-stylecolorpurplestylesolid, hatched, dotted or outlined. One style, or a list violin by violin.fill-style-stylesolidbandboxplot's and a scatter's band: are shares of, so a narrow box sits inside a wide violin by giving each its own share.0.8opacity1label$maths$ and inline formatting render. Fades and draws with the element.hiddenhidden: true !cue.to{false}(at: 2) reveals it — and unlike a cue, a hidden element still frames the plot and holds its slot, so nothing moves when it appears.falselockeditable: graph. Nothing at all on a graph that is not editable.lockedfalsetext-size20layergroupgroup: Treated, Projected. It is drawn in the colour of the first group that has one, over its own colour:, and the footer's key names every group. A stroke the graph's key: gives a group does not change it.xplanexx: and y: together, with one axis ruled in names, are a sample grouped by those names, a violin at each.violin:valuexyplanexx: and y: together, with one axis ruled in names, are a sample grouped by those names, a violin at each.violin:valueyonboxplot's on:. Required on a plane for a violin written with one coordinate; refused on the number line, whose violins take lanes, and on a grouped violin, whose names column already says where.argandplanereimonboxplot's on:. Required on a plane for a violin written with one coordinate; refused on the number line, whose violins take lanes, and on a grouped violin, whose names column already says where.#Derived attributes
Computed while the element renders — read one with #id.name in attribute position or {{#id.name}} in prose, never set.
countmeanmediansd#Allowed in
#Examples


graph:x{
violin(x: 2, 3, 3, 4, 4, 5, 7, 8, 8, 9)
}

graph{
violin(x: #penguins.flipper; y: #penguins.species)
}

graph{
violin(y: #trial.mass; on: control; bandwidth: 0.4)
}