Data Trends>Data Visualization

Density Plot: How to Read, Compare, and Use One

A dataset can contain thousands of observations, but looking at individual values rarely reveals the full picture. You might know the average customer response time, for example, but that number won't tell you whether most responses arrive within a few seconds or whether a small number of unusually slow responses are pulling the average up.

A density plot helps reveal that bigger picture.

By turning individual observations into a smooth curve, it shows where values are concentrated, how a distribution is shaped, and whether multiple peaks or long tails exist. It's particularly useful when you want to understand and compare continuous data without relying entirely on individual counts or summary statistics.

However, a density plot is an estimate, not a direct representation of the observations. The smoothing method can influence what you see, and interpreting the curve incorrectly can lead to misleading conclusions.

This guide explains how density plots work, how to interpret them, when to use them instead of histograms, and how to create them in Python and R.

What Is a Density Plot?

A density plot is a visualization that represents the distribution of a continuous numerical variable using a smooth curve.

Unlike a histogram, which groups observations into intervals called bins, a density plot estimates the distribution across a continuous range of values.

For example, imagine analyzing the time it takes a customer support team to respond to incoming requests. A density plot could help you identify:

  • Where response times are most concentrated.

  • Whether response times are skewed toward longer durations.

  • Whether the data contains multiple apparent peaks.

  • How response-time distributions differ between teams or service tiers.

The curve is generally created using kernel density estimation (KDE), a statistical technique that estimates the probability density function from observed data.

The important distinction is that a density plot does not display exact observation counts. It provides an estimate of how the observations are distributed.

Understanding the axes

A typical density plot has two axes:

  • X-axis: Represents the variable being measured, such as response time in seconds, customer spending, or delivery duration.

  • Y-axis: Represents estimated probability density, indicating how concentrated observations are around different values.

The y-axis is often misunderstood. A density value of 0.8 does not mean that 80% of observations fall at that exact point.

Instead, probability is represented by the area under the curve across a range of values. For a normalized density curve, the total area under the curve equals 1.

For example, if a response-time distribution has a broad peak between 2 and 4 seconds, this suggests that observations are relatively concentrated in that interval.

The height of the curve indicates density, while the area across an interval represents the proportion of observations within that range.

How to Interpret a Density Plot

Reading a density plot involves more than identifying its highest point. The overall shape can reveal important characteristics of the underlying data.

Here are the main features to examine.

1. Peaks

A peak represents a region where the estimated density is relatively high.

Consider a dataset containing customer purchase amounts. If the density plot has a prominent peak around $50, it suggests that purchases are concentrated around that value.

Multiple peaks may indicate distinct groups within the dataset.

For instance, customer spending might show two apparent peaks corresponding to occasional buyers and high-value customers.

However, multiple peaks do not automatically prove that separate customer segments exist. Check whether the pattern remains visible under reasonable smoothing settings and investigate the underlying records.

2. Skewness

Skewness describes the asymmetry of a distribution.

A density plot can help identify two common patterns:

  • Right-skewed distribution: The curve has a longer tail toward higher values. This can occur when a small number of observations are substantially larger than most others.

  • Left-skewed distribution: The curve has a longer tail toward lower values.

For example, customer purchase values may be right-skewed if most customers spend relatively small amounts while a few make exceptionally large purchases.

Recognizing skewness is useful when deciding whether the mean or median better represents a dataset.

3. Spread

The spread indicates how widely observations are distributed.

A narrow curve generally suggests that values are concentrated within a smaller range. A wider curve suggests greater variation.

For example, comparing delivery times across two warehouses may reveal that one consistently delivers within a narrow time range, while the other has considerably more variation.

4. Overlapping distributions

When comparing multiple groups, overlapping curves indicate regions where their estimated distributions occupy similar ranges.

Less overlap may suggest differences in the distributions, although it does not establish statistical significance.

For a meaningful comparison, consider the sample sizes, normalization settings, and bandwidth used for each curve.

Density Plot vs. Histogram: What's the Difference?

Density plots and histograms are both used to understand numerical distributions, but they present data differently.

FeatureHistogramDensity Plot
VisualizationBarsSmooth curve
Data representationGroups observations into binsEstimates a continuous distribution
Y-axisCount, frequency, or densityProbability density
Main parameterBin widthBandwidth
Best suited forCounts and frequency patternsUnderstanding distribution shape
Common limitationAppearance changes with bin selectionAppearance changes with smoothing

When should you use a histogram?

Choose a histogram when you need to understand how many observations fall within particular intervals.

It is especially useful when:

  • Your audience needs actual counts or frequencies.

  • The dataset contains many repeated values.

  • You're working with discrete or integer-valued data.

  • You want to examine gaps and individual frequency patterns.

When should you use a density plot?

A density plot is useful when you want a smooth representation of continuous data.

Consider using one when:

  • You want to understand the overall shape of a distribution.

  • You're comparing a small number of continuous variables across groups.

  • You want to identify possible skewness or multiple peaks.

  • You want to compare distributions without relying on histogram bin boundaries.

A practical tip: When the choice isn't obvious, display both a histogram and a density curve. The histogram preserves the frequency information, while the density curve makes the overall distribution easier to examine.

How Kernel Density Estimation (KDE) Works

Kernel density estimation is the method commonly used to generate density plots.

Rather than placing observations into predefined bins, KDE places a smooth function, called a kernel, around each observation. These individual functions are combined to produce an overall density estimate.

A Gaussian kernel is commonly used.

The resulting curve depends on two important choices:

  1. The kernel function.

  2. The bandwidth used to control smoothing.

What is bandwidth?

Bandwidth determines how much smoothing is applied when estimating the density curve.

It has a significant effect on the final visualization.

A smaller bandwidth produces a more detailed curve with sharper peaks and valleys. However, it can also make random fluctuations look like meaningful patterns.

A larger bandwidth produces a smoother curve but may hide important features, such as separate peaks or smaller clusters.

There is no single bandwidth that works best for every dataset.

A useful approach is to generate density plots with several reasonable bandwidth settings and compare the results.

If an apparent second peak disappears when the bandwidth changes slightly, treat that feature cautiously.

The goal is not to produce the smoothest or most visually appealing curve. It is to produce an estimate that represents the data appropriately.

How to Create a Density Plot in Python and R

Most statistical visualization libraries provide built-in functions for creating density plots.

Before generating one, inspect your dataset for missing values, repeated observations, natural boundaries, and unusual values.

Creating a density plot in Python

Python's Seaborn library provides the kdeplot() function for creating kernel density estimates.

import seaborn as sns
import matplotlib.pyplot as plt

# Load an example dataset
tips = sns.load_dataset("tips")

# Create a density plot
sns.kdeplot(
    data=tips,
    x="total_bill",
    fill=True
)

plt.xlabel("Total Bill ($)")
plt.ylabel("Density")
plt.title("Distribution of Restaurant Bills")

plt.show()

This example uses restaurant bill amounts to illustrate how observations are distributed.

You can also compare distributions across groups:

sns.kdeplot(
    data=tips,
    x="total_bill",
    hue="time",
    fill=False
)

plt.xlabel("Total Bill ($)")
plt.ylabel("Density")
plt.title("Restaurant Bills by Time of Day")

plt.show()

This produces separate density curves for lunch and dinner transactions.

When interpreting grouped curves, remember that Seaborn's normalization settings matter. Its default common_norm=True normalizes the combined distribution, while common_norm=False normalizes each group independently.

Creating a density plot in R

In R, the ggplot2 package provides geom_density() for generating density plots.

library(ggplot2)

ggplot(data = diamonds, aes(x = price)) +
  geom_density(fill = "skyblue", alpha = 0.5) +
  labs(
    title = "Distribution of Diamond Prices",
    x = "Price ($)",
    y = "Density"
  ) +
  theme_minimal()

This example visualizes the distribution of diamond prices.

To compare distributions across categories, map a grouping variable to the color aesthetic:

ggplot(diamonds, aes(x = price, color = cut)) +
  geom_density() +
  labs(
    title = "Diamond Price Distribution by Cut",
    x = "Price ($)",
    y = "Density",
    color = "Cut"
  )

The resulting curves allow you to examine how price distributions differ across diamond cuts.

Regardless of the programming language, creating the curve is only the first step. Review the bandwidth, axis labels, and underlying observations before drawing conclusions.

How to Compare Multiple Density Plots

Density plots become particularly useful when you want to compare the distribution of a variable across different groups.

For example, a business might compare customer spending across regions or examine response times across service teams.

A few visualization practices can make these comparisons easier to interpret.

Use distinct colors: Assign a consistent color to each group so readers can distinguish the distributions.

Avoid excessive overlap: When several filled curves overlap, use unfilled line plots or separate panels.

Keep scales consistent: Use comparable axis ranges and normalization settings when the goal is to compare distribution shapes.

Consider group sizes: A normalized density curve describes a distribution's shape, not necessarily the number of observations in a group.

Check bandwidth consistency: Different smoothing settings can create misleading visual differences between groups.

For example, when comparing customer spending across regions, a similar distribution shape does not necessarily mean the regions have the same number of customers. Always consider sample size alongside the density curves.

The purpose of the comparison is to identify patterns worth investigating, not to treat visual differences as proof of a statistical relationship.

Common Density Plot Mistakes to Avoid

Although density plots are useful, they can also make data appear more straightforward than it really is.

Understanding their limitations helps prevent misleading interpretations.

1. Treating density as probability

The height of the curve does not represent the probability of observing one exact value.

Probability is calculated from the area under the curve across an interval.

2. Choosing an inappropriate bandwidth

Excessive smoothing can hide important patterns, while insufficient smoothing can exaggerate random fluctuations.

Compare multiple reasonable settings rather than relying blindly on software defaults.

3. Ignoring natural boundaries

A KDE curve can extend beyond the actual range of possible values.

For example, a response-time variable cannot be negative, but an unconstrained density estimate may extend below zero.

In Seaborn, the cut=0 parameter limits the displayed curve to the observed data range. However, this does not eliminate all boundary-related estimation issues.

When observations cluster near a natural boundary, consider whether a different visualization or estimation method would be more appropriate.

4. Using density plots for discrete data

A smooth curve may suggest continuity where the underlying observations are actually separate values.

For example, customer satisfaction scores recorded on a scale from 1 to 5 may be better represented using a count plot or histogram.

5. Comparing curves without considering sample sizes

Two groups can have similar-looking density curves despite having very different numbers of observations.

Remember that normalized density plots emphasize distributions rather than raw group sizes.

If group size matters, display the sample counts alongside the curves.

6. Treating apparent peaks as confirmed segments

Multiple peaks can suggest that a dataset contains distinct subgroups, but smoothing choices and sampling variation can also create apparent clusters.

Investigate the underlying observations and relevant grouping variables before assigning meaning to those peaks.

Taking Density Plot Analysis Further

A density plot helps you understand how numerical data is distributed, but the most useful insights often come from investigating the patterns behind the curve.

Suppose a customer support team notices a long right tail in its response-time distribution. The visualization identifies an area worth examining, but it doesn't explain why some requests take considerably longer to receive a response.

That requires further analysis.

You might investigate response times by request category, service team, customer segment, or time of day to identify where delays occur.

This is where interactive analytics becomes useful. Tools such as ThoughtSpot allow analysts to explore related business metrics, filter data, and investigate patterns across different dimensions.

Rather than treating a density plot as the final answer, use it as a starting point for more focused questions.

Conclusion

A density plot provides a useful way to understand the distribution of continuous numerical data. It helps reveal concentration, spread, skewness, and possible differences between groups through a smooth estimated curve.

However, its usefulness depends on choosing an appropriate visualization, understanding KDE and bandwidth, and interpreting density correctly.

Use histograms when counts and frequencies matter. Use density plots when a smooth view of distribution shape helps answer your question. When necessary, combine both to preserve detail without losing the bigger picture.

Most importantly, treat the curve as an estimate rather than a definitive representation of your data. The strongest analysis comes from connecting what you see in the visualization with the observations and business context behind it.

Frequently Asked Questions

What is a density plot?

A density plot is a graphical representation of the distribution of a continuous numerical variable. It uses a smooth curve, typically generated through kernel density estimation, to show where observations are concentrated.

What does the y-axis represent in a density plot?

The y-axis represents estimated probability density, not raw counts or the probability of one exact value. For a normalized density curve, the total area under the curve equals 1.

What is the difference between a density plot and a histogram?

A histogram groups observations into bins and displays their counts or frequencies. A density plot uses smoothing to estimate a continuous distribution. Histograms are useful for examining frequencies, while density plots help visualize distribution shape.

What is KDE in a density plot?

KDE stands for kernel density estimation. It is a statistical method that combines smooth functions around individual observations to estimate an overall probability density function.

How does bandwidth affect a density plot?

Bandwidth determines the amount of smoothing applied to the density estimate. A smaller bandwidth produces a more detailed curve but may exaggerate noise. A larger bandwidth creates a smoother curve but can hide meaningful patterns.

When should you use a density plot?

Use a density plot when analyzing continuous numerical variables and when understanding distribution shape, spread, skewness, or differences between groups is important. For discrete data or situations where exact counts matter, a histogram or count plot may be more appropriate.

Can a density plot show multiple distributions?

Yes. Multiple density curves can be displayed on the same chart to compare different groups. Use distinct colors, consistent scales, and appropriate normalization settings to make the comparison meaningful.

The Leader in Agentic Analytics

2026 Leader

2026 Leader

2026 G2 Enterprise

2026 G2 Enterprise

2026 G2 SMB

2026 G2 SMB

2026 G2 Momentum

2026 G2 Momentum