Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Bin data into hexagon tiles
ResourceFunction["HextileBins"][mat,r] bins a numerical full 2D array mat into hexagon grid tiles with radius r. | |
ResourceFunction["HextileBins"][cv,r] bins coordinates-to-value rules cv. |
Create a list of random 2D points:
In[1]:= |
Bin the points:
In[2]:= |
Out[2]= |
Bin the points and get the hex-tile centers as keys:
In[3]:= |
Out[3]= |
Plot the points and the hexagon bins:
In[4]:= |
Out[4]= |
Associate random values to 2D data:
In[5]:= |
Bin the data rules:
In[6]:= |
Out[6]= |
Bin the keys of the data rules:
In[7]:= |
Out[7]= |
Check the equivalence:
In[8]:= |
Out[8]= |
Bin the data rules and compute average values on each tile:
In[9]:= |
Out[6]= |
Compare with the default option value Total:
In[10]:= |
Out[10]= |
Instead of polygons as keys, you can get the centers of the polygons:
In[11]:= |
Out[12]= |
Generate data rules:
In[13]:= |
Here we bin the data:
In[14]:= |
Plot points and hexagon bins by coloring each hexagon according to its aggregated value:
In[15]:= |
Out[15]= |
You can make hexagonal grids:
In[16]:= |
Out[17]= |
The coordinates of the polygons can be retrieved and transformed further:
In[18]:= |
Out[18]= |
The function GeoHistogram produces similar plots (in Version 12.1):
In[19]:= |
In[20]:= |
In[21]:= |
In[22]:= |
Out[22]= |
The resource function HexagonalGridGraph can be also used to make hexagonal grids:
In[23]:= |
Out[23]= |
Here are the corresponding coordinates:
In[24]:= |
Out[24]= |
Here are the corresponding polygons:
In[25]:= |
Out[15]= |
Make a similar grid with HextileBins:
In[26]:= |
Out[27]= |
Here are the corresponding coordinates:
In[28]:= |
Out[28]= |
The resource function TileBins has similar design and implementation as HextileBins. Here are comparable examples:
In[29]:= |
Out[29]= |
Bin data and summarize the values associated with bin centers:
In[30]:= |
In[31]:= |
Out[31]= |
This work is licensed under a Creative Commons Attribution 4.0 International License