heatmap_scatter
This is a simple wrapper around the scatter function that uses a Euclidean distance metric to count the number of entries in its proximity as a third dimension, which is represented by color.
It's fairly barebone, requiring your X and Y entries to be Nx1 vectors of identical length. It attempts to ignore outliers, but will do poorly if your data spans multiple orders of magnitude and you need to use log X or Y scale.
To test it out, just get your data into two Nx1 vectors and plug it in, you can tweak the needed settings from there.
Note that, if you want to enter graph settings such as marker size and color map but want automated distance thresholding, use [] for that argument.
It allows you to plug the graph directly into a subplot if you first make a subplot with:
sub_ax = subplot(n,n,i);
heatmap_scatter(x_vals, y_vals, [], false, 10, 'jet',sub_ax)
Hope it helps!
Cite As
gchao (2026). heatmap_scatter (https://www.mathworks.com/matlabcentral/fileexchange/89172-heatmap_scatter), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.1.1 | Fixed description |
||
| 1.1.0 | Removed the previously very aggressive auto scaling function for x and y axis limits. Users can use xlim and ylim to do this manually. Added a field for linear vs log coloring for scatters that vary in density variation in orders of magnitudes. |
||
| 1.0.0 |
