File Exchange

image thumbnail


version (31.3 KB) by Erik
Tools for hexagonal binning (honeycomb plot) and visualisation


Updated 12 May 2020

GitHub view license on GitHub

Put all files somewhere on your MATLAB path. At least, honeycomb.m and the private directory (with contents) should be in the same directory on the MATLAB path.
Run help honeycomb or doc honeycomb for instructions.

The following code produces the image seen on this page.

x = randn(100);
y = rand(size(x));
honeycomb(x, y)
title 'Honeycomb plot of uniform vs. normal random data'

The files that inspired this file are listed on this page, but do not contain the same functionality due to different use cases or bugs. Therefore I developed my own implementation of the hexagonal scatter plot. Other sources include: (hexbin for R) (scientific article using honeycomb plots, you may not have access to the journal)

The true version of this release is 0.1 (as per GitHub), but the File Exchange does not allow version numbers lower than 1.x. Therefore, I've set the version to Future updates will bump the number to be identical on both File Exchange and GitHub.

Cite As

Erik (2020). Honeycomb (, GitHub. Retrieved .

Comments and Ratings (6)


@Adam Doyle
Thanks for the compliment. It does indeed look best with uniform hexagons. As you've stated correctly, then the hexagonal plot should also control the axes' aspect ratio, or the number of horizontal or vertical bins should change with changes in the aspect ratio. This is possible, but not in my (and probably most people's) interest to implement. Imagine how zooming should work: it could lead to some strange or difficult to control situations.

Adam Soule

This is exactly what I was looking for and it worked perfectly. Great job. The hex plots look best when the hexagons are uniform (not stretched), but I imagine it would be difficult to implement that without also controlling the figure aspect ratio.


@Yrobel Lima
What is the exact error message you are getting? What is the exact command that you used to call 'honeycomb(...)'? And what are the data types you used in that command? The basic syntax is 'honeycomb(x, y)', in which x and y are numeric.
Since the error is thrown on line 48: the 'Debug' Name-Value pair argument should not be used, unless you want to debug the plots, then it should be set to true.

Yrobel Lima

I have the following error:
Error in ==> honeycomb at 48
parser.addParameter('Debug', defaults.Debug, @islogical).

How can I associate a data series with this array?


Good job!

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Hexagonal Scatter Plot, hexscatter.m