Environmental science

Violin plot example: daily ozone by month

Violin plot of daily ozone in New York, May–September 1973, with unrecorded days kept as NA. June has only 9 readings, so its points stay on.

Open this example in the editorStart from scratch

050100150200Ozone (ppb)May (n = 26)June (n = 9)July (n = 26)August (n =26)September(n = 29)
Daily ozone (ppb) by month in 1973; 116 recorded days, 37 NA. June’s violin rests on 9 readings.

About this example

R’s datasets::airquality holds daily air-quality readings from New York between May and September 1973, from the New York State Department of Conservation and the National Weather Service. Ozone was not recorded on 37 of the 153 days. Those cells stay as NA: the editor counts them as missing for their month and never treats them as zero.

The months differ in how many readings they have: 26 in May, July and August, 29 in September and only 9 in June, when 21 days are missing. With fewer than 10 values an outline mostly reflects the bandwidth rather than the data, so June keeps its points even if you hide points elsewhere, and the figure says so. Report the accepted n with each month.

July and August reach well above 100 ppb, which widens their bandwidths to about 15 and 19 ppb; May and September stay near 7 ppb. Because each violin is trimmed to its own lowest and highest reading, no outline suggests ozone values that were never measured.

Sources: R datasets::airquality — NY State Dept. of Conservation, National Weather Service

The data

MonthOzone (ppb)
May41
May36
May12
May18
MayNA
May28
May23
May19
May8
MayNA
May7
May16
May11
May14
May18

…and 138 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.

More examples