Density Heatmap
Visualize 2D data density and distribution with color intensity
A density heatmap (also called 2D histogram or hexbin) shows the concentration of data points across two continuous variables. Unlike a scatter plot where individual points are plotted, a density heatmap divides the plane into bins and colors each bin based on the number of points it contains. This reveals patterns and concentrations that may be hidden in dense scatter plots.
Best used for:
- Visualizing large datasets where scatter plots become cluttered
- Identifying areas of high data concentration
- Revealing distribution patterns in bivariate data
- Detecting outliers and anomalies
- Understanding correlations between two variables
- Finding hotspots in spatial or measurement data
Common Use Cases
Data Analysis & Statistics
- Bivariate distribution analysis
- Correlation visualization for large datasets
- Identifying data clusters and patterns
- Outlier detection in 2D space
- Quality control and process monitoring
Scientific Research
- Particle density distribution
- Measurement correlation studies
- Experimental data patterns
- Spatial distribution analysis
- Signal processing and noise analysis
Business & Operations
- Customer behavior patterns (age vs purchase amount)
- Product performance (price vs sales volume)
- Geographic density (latitude vs longitude)
- Time-based activity patterns (hour vs metric)
- Resource utilization hotspots
Options
X Axis
Required - Numerical column for horizontal dimension.
Values are divided into bins along the X-axis. Must be continuous numerical data.
Y Axis
Required - Numerical column for vertical dimension.
Values are divided into bins along the Y-axis. Must be continuous numerical data.
Z Value (Optional)
Optional - Values to aggregate within each bin.
If not specified, bins show count of data points. When specified, bins show aggregated values (e.g., sum, mean) of the Z column for points in that bin.
Settings
Hide Empty Values
Optional - Exclude bins with no data. When enabled, bins with zero values are not displayed (appear as background color).
Color Scale
Optional - Color scheme for density values.
Specify the color palette for the heatmap. Common options include:
Number of X Bins
Optional - How many bins to use for X-axis.
Controls the granularity of the heatmap horizontally. More bins show more detail but may introduce noise.
Number of Y Bins
Optional - How many bins to use for Y-axis.
Controls the granularity of the heatmap vertically.
Understanding Density Heatmap vs Scatter Plot
Use Scatter Plot When:
- Dataset is small (< 1,000 points)
- Need to see individual data points
- Examining exact positions is important
- Data is sparse
Use Density Heatmap When:
- Dataset is large (> 10,000 points)
- Individual points create overplotting
- Interested in overall patterns and concentrations
- Want to see distribution density
Bin Configuration
Too Few Bins
- Pro: Clear, simple visualization
- Pro: Less affected by noise
- Con: Loss of detail
- Con: May miss important patterns
Too Many Bins
- Pro: High detail and resolution
- Pro: Captures subtle patterns
- Con: May be noisy
- Con: Slower to render
Optimal Bins
- Start with default (20×20)
- Increase if patterns look blocky
- Decrease if too noisy or sparse
- Balance between detail and clarity
Tips for Effective Density Heatmaps
-
Choose Bin Count Wisely:
- Start with defaults (20×20)
- Increase for large datasets with clear patterns
- Decrease for sparse data or small datasets
- Keep X and Y bins proportional to data ranges
-
Color Scale Selection:
- Viridis/Plasma: Best for general use, colorblind-friendly
- Sequential (Blues, Reds): When direction doesn't matter
- Diverging (RdYlBu): When middle value is meaningful
- Ensure sufficient contrast for all density levels
-
Handle Large Datasets:
- Density heatmap performs well with millions of points
- Consider sampling if performance is slow
- Use Z value aggregation for meaningful summaries
- Filter outliers if they compress main distribution
-
Combine with Other Plots:
- Add marginal distributions (histograms) for each axis
- Overlay contour lines for specific density levels
- Add scatter plot layer for outliers
- Show summary statistics in annotations
-
Interpretation Tips:
- Dark/bright areas indicate high concentration
- Empty/light areas indicate low concentration
- Diagonal patterns suggest correlation
- Clusters indicate multimodal distributions
-
Z Value Usage:
- Leave empty for simple density (count)
- Use for weighted density (e.g., sum of sales amounts)
- Useful for aggregating measurements in each bin
- Consider mean/median for average behavior in regions
Example Scenarios
Customer Analysis
Age vs Purchase Amount - reveals customer segments and spending patterns
Measurement Correlation
Two correlated measurements showing linear relationship with scatter
Spatial Density
Latitude vs Longitude - shows geographic concentrations
Time-Based Patterns
Hour of Day vs Metric Value - reveals temporal patterns
Comparison with Related Plots
vs Standard Heatmap
- Density Heatmap: Bins continuous numerical data
- Standard Heatmap: Shows values for discrete categories
- Use density for X/Y both numerical and continuous
vs Scatter Plot
- Density Heatmap: Shows concentration, better for large data
- Scatter Plot: Shows individual points, better for small data
- Density heatmap solves overplotting problem
vs Contour Plot
- Density Heatmap: Rectangular bins with discrete colors
- Contour Plot: Smooth curves at density levels
- Density heatmap easier to read, contour plot more precise
Troubleshooting
Issue: All bins show similar colors
- Solution: Data range is too narrow or bins are too coarse. Check if data has outliers compressing the scale. Consider filtering extreme values or using log scale.
Issue: Most bins are empty
- Solution: Too many bins for the amount of data. Reduce "Number of X Bins" and "Number of Y Bins" to show concentrations better.
Issue: Pattern looks too blocky
- Solution: Increase number of bins to get finer resolution. Ensure bins are appropriate for data density.
Issue: Cannot see low-density regions
- Solution: Adjust color scale, use log scaling, or filter high-density regions to see detail in low-density areas.
Issue: Rendering is slow
- Solution: Reduce number of bins, filter data to relevant range, or sample large datasets before plotting.
Issue: Hotspots appear as single bins
- Solution: Increase bin count to get better resolution of concentrated areas. Current bins are too coarse.
Issue: Outliers compress the main visualization
- Solution: Filter outliers before plotting, or set explicit axis ranges to focus on main data distribution.
Issue: Can't distinguish density levels
- Solution: Try different color scales. Viridis and Plasma work well for most cases. Ensure sufficient contrast in selected palette.