datarekha
Data Visualization Easy Asked at GoogleAsked at Netflix

What is the difference between a histogram, a bar chart, and a KDE plot, and when do you use each?

The short answer

A bar chart displays counts or aggregates for distinct categories separated by gaps; a histogram displays the distribution of a single continuous variable by dividing it into adjacent bins with no gap; a KDE (kernel density estimate) plot is a smoothed, continuous approximation of the same distribution without requiring a bin-width choice.

How to think about it

Bar chart — categorical, discrete

Bar charts have gaps between bars because the x-axis categories are nominal or ordinal with no inherent continuity. The height encodes an aggregate (count, sum, mean). You can reorder bars arbitrarily, which is often useful (sort descending by value). Example: number of support tickets by product category.

Histogram — continuous, distribution

A histogram divides a continuous variable into contiguous bins and counts how many observations fall in each. The bars touch because adjacent bins share a boundary — there is no gap between 10–20 and 20–30. The area of each bar is proportional to frequency (when using density normalization). The choice of bin width is consequential: too few bins and you hide the shape; too many and noise dominates. Common heuristics: Sturges’ rule (k = 1 + log2(n)), Scott’s rule (bin width = 3.5 * std / n^(1/3)), or Freedman-Diaconis (uses IQR). Example: distribution of session durations.

KDE plot — continuous, smoothed

A KDE replaces the step-function histogram with a smooth curve by placing a kernel (usually Gaussian) on each data point and summing. It avoids the bin-width choice but introduces a bandwidth parameter (h) that has similar sensitivity. KDE is preferable when you want to overlay multiple distributions (e.g., one per class) because overlapping smooth curves are easier to read than overlapping histograms.

PropertyBarHistogramKDE
Data typeCategoricalContinuousContinuous
Bars touch?NoYesN/A (line)
Bin width needed?NoYesNo (bandwidth)
Best for overlays?NoPartialYes

When to use a box plot instead

If your goal is comparing distributions across multiple groups rather than showing the shape of one distribution, a box plot or violin plot is more efficient. The box encodes the median and IQR; whiskers extend to 1.5x IQR; points beyond are individual outliers — all in a compact glyph that scales to many groups side by side.

Learn it properly Distributions

Keep practising

All Data Visualization questions

Explore further

Skip to content