Skip to content

Commit

Permalink
Release v0.1 (#17)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
erikhuizinga authored Mar 30, 2017
1 parent dcdc3b3 commit a1933f9
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 1 deletion.
77 changes: 77 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

# Created by https://www.gitignore.io/api/macos,windows,matlab

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Matlab ###
##---------------------------------------------------
## Remove autosaves generated by the Matlab editor
## We have git for backups!
##---------------------------------------------------

# Windows default autosave extension
*.asv

# OSX / *nix default autosave extension
*.m~

# Compiled MEX binaries (all platforms)
*.mex*

# Simulink Code Generation
slprj/

# Session info
octave-workspace

# Simulink autosave extension
.autosave

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/macos,windows,matlab
119 changes: 119 additions & 0 deletions .test/testHoneycomb.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
%% Test honeycomb
%TODO
% - Test data on edges: 6 edges between hexagons, outer edges of entire grid,
% corners of hexagons


%% Initialize
clear
close all


%% Test basic input arguments
% Set number of elements
n = 50; % Will be squared
c = 3;

% Generate x
x = randn(n);
preX = c * [-1; -1; 1; 1];
x(1 : numel(preX)) = preX;

% Generate y
y = randn(size(x));
preY = c * [-1; 1; -1; 1];
y(1 : numel(preY)) = preY;


% Test honeycomb
figure
honeycomb(x, y)
title 'Default'
colorbar


%% Test data validation and parsing
% Generate unplottable data
xNaN = NaN(size(x));
xNaN(end) = 1;
yNaN = y;
yNaN(end) = NaN;

% Test unplottable data
figure
honeycomb(xNaN, yNaN, 'Debug', true)
title 'Only NaN'
colorbar


% Test empty data
% This must return a valid patch object, e.g., compare to
% h = scatter([], [])
figure
p = honeycomb([], [], 'Debug', true);
title 'Empty data'
colorbar
assert(isa(p, 'matlab.graphics.primitive.Patch'), ...
'output argument of honeycomb must be a Patch object')


% Test singleton data
figure
honeycomb(-1, pi, 'Debug', true)
title 'Singleton data'
colorbar


% Test singleton data with specifed number of bins
figure
honeycomb(-pi, 1, 1, 'Debug', true)
title 'Singleton data in one bin'
colorbar

figure
honeycomb(exp(1), sqrt(2), 2, 'Debug', true)
title 'Singleton data in 2 bins'
colorbar

figure
honeycomb(exp(-2), -sqrt(3), [3, 2], 'Debug', true)
title 'Singleton data in [3, 2] bins'
colorbar


% Test invalid data
isExceptionThrown = false;
try
figure
honeycomb(1i, 2, 'Debug', true)
catch
title 'Invalid data, empty plot'
isExceptionThrown = true;
end
assert(isExceptionThrown, 'an exception must be thrown')


%% Test validation and parsing of number of bins
% Test drawing one hexagonal bin
figure
honeycomb(x, y, 1, 'Debug', true)
title 'One bin'
colorbar

% Test drawing lots of bins
figure
honeycomb(x, y, 100, 'Debug', true)
title '100 bins'
colorbar

% Test drawing one horizontal hexagonal bin against many vertical bins
figure
honeycomb(x, y, [1, 10], 'Debug', true)
title '[1, 10] bins'
colorbar

% Test drawing one vertical hexagonal bin against many horizontal bins
figure
honeycomb(x, y, [10, 1], 'Debug', true)
title '[10, 1] bins'
colorbar
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# honeycomb
Tools for hexagonal binning (honeycomb plot) and visualisation
> Tools for hexagonal binning (honeycomb plot) and visualisation
## Installation
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.

## Documentation
Run `help honeycomb` or `doc honeycomb` for instructions.

## Example
```matlab
x = randn(100);
y = rand(size(x));
figure
honeycomb(x, y)
colorbar
title 'Honeycomb plot of uniform vs. normal random data'
```

Result:

![honeycomb](https://cloud.githubusercontent.com/assets/19374736/24495979/3f70f6f6-1537-11e7-8203-523ae248bffa.png)
Loading

0 comments on commit a1933f9

Please sign in to comment.