Skip to content

Commit a1933f9

Browse files
authored
Release v0.1 (#17)
* Configure .gitignore * Add license * v0.1-rc (#15) * Stub honeycomb unit test * Initialize hexagon grid based on data range * Test hexagon grid initialization * Fix hexagon initialization * Add bivariate histogram to test * Sort hexagons from top to bottom and right to left * Test more random data * Move debug code to end * Rearrange code and comments * Determine bin counts * Draw hexagons * Validate input arguments and add output argument * Test input validation and parsing * Add Debug input argument * Add help * Update help and add copyright info * Update license * Update help * Update README.md * Update help * Update README.md
1 parent dcdc3b3 commit a1933f9

File tree

8 files changed

+575
-1
lines changed

8 files changed

+575
-1
lines changed

.gitignore

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
# Created by https://www.gitignore.io/api/macos,windows,matlab
3+
4+
### macOS ###
5+
*.DS_Store
6+
.AppleDouble
7+
.LSOverride
8+
9+
# Icon must end with two \r
10+
Icon
11+
12+
13+
# Thumbnails
14+
._*
15+
16+
# Files that might appear in the root of a volume
17+
.DocumentRevisions-V100
18+
.fseventsd
19+
.Spotlight-V100
20+
.TemporaryItems
21+
.Trashes
22+
.VolumeIcon.icns
23+
.com.apple.timemachine.donotpresent
24+
25+
# Directories potentially created on remote AFP share
26+
.AppleDB
27+
.AppleDesktop
28+
Network Trash Folder
29+
Temporary Items
30+
.apdisk
31+
32+
### Matlab ###
33+
##---------------------------------------------------
34+
## Remove autosaves generated by the Matlab editor
35+
## We have git for backups!
36+
##---------------------------------------------------
37+
38+
# Windows default autosave extension
39+
*.asv
40+
41+
# OSX / *nix default autosave extension
42+
*.m~
43+
44+
# Compiled MEX binaries (all platforms)
45+
*.mex*
46+
47+
# Simulink Code Generation
48+
slprj/
49+
50+
# Session info
51+
octave-workspace
52+
53+
# Simulink autosave extension
54+
.autosave
55+
56+
### Windows ###
57+
# Windows thumbnail cache files
58+
Thumbs.db
59+
ehthumbs.db
60+
ehthumbs_vista.db
61+
62+
# Folder config file
63+
Desktop.ini
64+
65+
# Recycle Bin used on file shares
66+
$RECYCLE.BIN/
67+
68+
# Windows Installer files
69+
*.cab
70+
*.msi
71+
*.msm
72+
*.msp
73+
74+
# Windows shortcuts
75+
*.lnk
76+
77+
# End of https://www.gitignore.io/api/macos,windows,matlab

.test/testHoneycomb.m

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
%% Test honeycomb
2+
%TODO
3+
% - Test data on edges: 6 edges between hexagons, outer edges of entire grid,
4+
% corners of hexagons
5+
6+
7+
%% Initialize
8+
clear
9+
close all
10+
11+
12+
%% Test basic input arguments
13+
% Set number of elements
14+
n = 50; % Will be squared
15+
c = 3;
16+
17+
% Generate x
18+
x = randn(n);
19+
preX = c * [-1; -1; 1; 1];
20+
x(1 : numel(preX)) = preX;
21+
22+
% Generate y
23+
y = randn(size(x));
24+
preY = c * [-1; 1; -1; 1];
25+
y(1 : numel(preY)) = preY;
26+
27+
28+
% Test honeycomb
29+
figure
30+
honeycomb(x, y)
31+
title 'Default'
32+
colorbar
33+
34+
35+
%% Test data validation and parsing
36+
% Generate unplottable data
37+
xNaN = NaN(size(x));
38+
xNaN(end) = 1;
39+
yNaN = y;
40+
yNaN(end) = NaN;
41+
42+
% Test unplottable data
43+
figure
44+
honeycomb(xNaN, yNaN, 'Debug', true)
45+
title 'Only NaN'
46+
colorbar
47+
48+
49+
% Test empty data
50+
% This must return a valid patch object, e.g., compare to
51+
% h = scatter([], [])
52+
figure
53+
p = honeycomb([], [], 'Debug', true);
54+
title 'Empty data'
55+
colorbar
56+
assert(isa(p, 'matlab.graphics.primitive.Patch'), ...
57+
'output argument of honeycomb must be a Patch object')
58+
59+
60+
% Test singleton data
61+
figure
62+
honeycomb(-1, pi, 'Debug', true)
63+
title 'Singleton data'
64+
colorbar
65+
66+
67+
% Test singleton data with specifed number of bins
68+
figure
69+
honeycomb(-pi, 1, 1, 'Debug', true)
70+
title 'Singleton data in one bin'
71+
colorbar
72+
73+
figure
74+
honeycomb(exp(1), sqrt(2), 2, 'Debug', true)
75+
title 'Singleton data in 2 bins'
76+
colorbar
77+
78+
figure
79+
honeycomb(exp(-2), -sqrt(3), [3, 2], 'Debug', true)
80+
title 'Singleton data in [3, 2] bins'
81+
colorbar
82+
83+
84+
% Test invalid data
85+
isExceptionThrown = false;
86+
try
87+
figure
88+
honeycomb(1i, 2, 'Debug', true)
89+
catch
90+
title 'Invalid data, empty plot'
91+
isExceptionThrown = true;
92+
end
93+
assert(isExceptionThrown, 'an exception must be thrown')
94+
95+
96+
%% Test validation and parsing of number of bins
97+
% Test drawing one hexagonal bin
98+
figure
99+
honeycomb(x, y, 1, 'Debug', true)
100+
title 'One bin'
101+
colorbar
102+
103+
% Test drawing lots of bins
104+
figure
105+
honeycomb(x, y, 100, 'Debug', true)
106+
title '100 bins'
107+
colorbar
108+
109+
% Test drawing one horizontal hexagonal bin against many vertical bins
110+
figure
111+
honeycomb(x, y, [1, 10], 'Debug', true)
112+
title '[1, 10] bins'
113+
colorbar
114+
115+
% Test drawing one vertical hexagonal bin against many horizontal bins
116+
figure
117+
honeycomb(x, y, [10, 1], 'Debug', true)
118+
title '[10, 1] bins'
119+
colorbar

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
11
# honeycomb
2-
Tools for hexagonal binning (honeycomb plot) and visualisation
2+
> Tools for hexagonal binning (honeycomb plot) and visualisation
3+
4+
## Installation
5+
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.
6+
7+
## Documentation
8+
Run `help honeycomb` or `doc honeycomb` for instructions.
9+
10+
## Example
11+
```matlab
12+
x = randn(100);
13+
y = rand(size(x));
14+
figure
15+
honeycomb(x, y)
16+
colorbar
17+
title 'Honeycomb plot of uniform vs. normal random data'
18+
```
19+
20+
Result:
21+
22+
![honeycomb](https://cloud.githubusercontent.com/assets/19374736/24495979/3f70f6f6-1537-11e7-8203-523ae248bffa.png)

0 commit comments

Comments
 (0)