Density Plots

When the statistics are low, histograms are ineffective at determining the shape of a distribution, because they are so strongly affected by the number of bins used.

A density plot is an alternative, in order to see the distribution of the data. It uses an estimation technique to convert the histogram into a continuous curve and plot the probability distribution of the data. The area of a density plot is usually scaled to unity.

Sometimes, you might need to compare two histograms with different amounts of data, while also wanting to see the shapes of the histograms. For example, you might wish to compare the age distribution of clients from a bigger and a smaller company that sell similar products. You would like to overlay ...

Get Applied Data Visualization with R and ggplot2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.