hexscatter.m

版本 1.1.0.0 (5.1 KB) 作者: Gordon
Generate a density plot using hexagonal patches.
1.4K 次下载
更新时间 2014/2/24

查看许可证

When the number of elements in a scatter plot is large, the plot becomes saturated, and the true shape of the data becomes obscured. One solution is to use a density plot, where the intensity of colored patches indicates the number of points falling withing 2D bins.
HEXSCATTER generates a density plot using hexagonal bins. Hexagonal bins are often preferred over square bins because they better maintain the original look and feel of a scatter plot, as opposed to looking like a heatmap.
Syntax
hexscatter(xdata, ydata)
hexscatter(xdata, ydata, 'Name', Value, ...)
h = hexscatter(...)

Description
hexscatter(xdata, ydata) creates a density plot of the ydata versus the
xdata using hexagonal tiles. xdata and ydata should be vectors. NaN
values (and their corresponding values in the other vector) are ignored.

hexscatter(xdata, ydata, 'Name', Value, ...) accepts name-value pairs of
arguments from the following list (defaults in {}):
'xlim' { [min(xdadta(:) max(xdata(:))] } - a 2-element vector containing
the lower and upper bounds of the 2nd dimension of the grid.
'ylim' { [min(ydadta(:) max(ydata(:))] } - a 2-element vector containing
the lower and upper bounds of the 1st dimension of the grid.
'res' { 50 } - the resolution, or number of bins in each dimension. The
total number of bins will be the resolution squared.
'drawEdges' { false } - if true, edges are drawn around each hexagonal
patch.
'showZeros' { false } - if true, bins with 0 counts are shaded; if
false, only bins with non-zero counts are colored.

h = hexscatter( ... ) returns the object handle to the patch object
created.

Examples
hexscatter(rand(2000,1), rand(2000,1))

hexscatter(rand(2000,1), rand(2000,1), 'res', 90)

Also available in the Bean Matlab Toolkit:
https://github.com/brazilbean/bean-matlab-toolkit

引用格式

Gordon (2024). hexscatter.m (https://www.mathworks.com/matlabcentral/fileexchange/45639-hexscatter-m), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2013b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Polygons 的更多信息
致谢

启发作品: Honeycomb

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.1.0.0

Added dependencies: default_param, get_params

1.0.0.0