Skip to main content
100%

Kernel Density Estimation to Violin Plot

✓ Published0🌍 Public
KKcnarf
Last edited Dec 3, 2018
Created on Aug 19, 2016

This example starts with a histogram and kernel density estimation for the Old Faithful eruption wait times from R's faithful dataset, then morphs the density curve into a violin plot. The animation transitions the curve from a line into a mirrored area, scaling it to half height, and fades the histogram and axis. Built with D3 v3, it uses `d3.svg.area`, `d3.layout.histogram`, and `transition.attr` to animate the shape, demonstrating how a density estimate becomes a violin plot.

AI-generated description

This block shows how to produce the contour of a Violin viz using a Kernel Density Estimation.

==original README==

Kernel density estimation is a method of estimating the probability distribution of a random variable based on a random sample. In contrast to a histogram, kernel density estimation produces a smooth estimate. The smoothness can be tuned via the kernel’s bandwidth parameter. With the correct choice of bandwidth, important features of the distribution can be seen, while an incorrect choice results in undersmoothing or oversmoothing and obscured features.

This example shows a histogram and a kernel density estimation for times between eruptions of Old Faithful Geyser in Yellowstone National Park, taken from R’s faithful dataset. The data follow a bimodal distribution; short eruptions are followed by a wait time averaging about 55 minutes, and long eruptions by a wait time averaging about 80 minutes. In recent years, wait times have been increasing, possibly due to the effects of earthquakes on the geyser’s geohydrology.

This example is based on a Protovis version by John Firebaugh.

gpl-3.0 Licensed

Similar vizzes