About this example
Edgar Anderson measured the flowers that R ships as datasets::iris, and Fisher used them in 1936. Petal length separates the species clearly: setosa petals cluster between 1.0 and 1.9 cm, while versicolor and virginica overlap between about 4.5 and 5.1 cm. With 50 flowers per species, a violin has enough values to show where they pile up.
Each violin uses its own automatic bandwidth, R’s bw.nrd0: about 0.054 cm for setosa, 0.18 cm for versicolor and 0.23 cm for virginica. The narrow setosa outline is therefore a real feature of the data, not a drawing choice. Equal-area scaling, the default, gives every species the same violin area, so a tall narrow violin and a short wide one hold the same share of flowers.
Petal lengths are recorded to 0.1 cm, so up to 13 setosa flowers share one value. This example opens with points hidden, because 50 tied dots do not fit side by side in an 85 mm figure; switch Observations to “All observations” on a wider figure to show every flower. The narrow box marks the median and quartiles, and the editor’s summary table lists each bandwidth so it can be quoted in a figure legend.
Sources: R datasets::iris — Anderson (1935), Fisher (1936)
The data
| Species | Petal length (cm) |
|---|---|
| setosa | 1.4 |
| setosa | 1.4 |
| setosa | 1.3 |
| setosa | 1.5 |
| setosa | 1.4 |
| setosa | 1.7 |
| setosa | 1.4 |
| setosa | 1.5 |
| setosa | 1.4 |
| setosa | 1.5 |
| setosa | 1.5 |
| setosa | 1.6 |
| setosa | 1.4 |
| setosa | 1.1 |
| setosa | 1.2 |
…and 135 more rows. Open the example to see all of them.
These are individual observations, not supplied group summaries. The editor reports its interpretation and preserves your selected presentation when loading an example. Open the example, replace the data with your own, and export the figure as SVG, PDF, PNG or TIFF.