hexalattice
Generate and plot hexagonal lattices in 2D, with fine control over spacing between hexagons, arbitrary rotation of the grid around central tile, etc. The module computes and returns the center point for each of the tiles in the lattice.
Installation
# Using pip
pip install hexalattice
# Using conda
conda install -c conda-forge hexalattice
Usage example
Create and plot 5x5 lattice of hexagons (as in first image):
from hexalattice.hexalattice import *
hex_centers, _ = create_hex_grid(nx=5,
ny=5,
do_plot=True)
plt.show() # import matplotlib.pyplot as plt
Get central points of the hexagons:
tile_centers_x = hex_centers[:, 0]
tile_centers_y = hex_centers[:, 1]
Plot one grid over the other, second with spacing around the hexagons:
_, h_ax = create_hex_grid(nx=5,
ny=7,
do_plot=True,
edge_color=(0.85, 0.85, 0.85))
create_hex_grid(nx=5,
ny=7,
do_plot=True,
edge_color=(0.25,0.25, 0.25),
h_ax=h_ax,
plotting_gap=0.3)
plt.show()
Create Moirֳ© pattern from two circularly cropped hexagrids:
hex_grid1, h_ax = create_hex_grid(nx=50,
ny=50,
rotate_deg=0,
min_diam=1,
crop_circ=20,
do_plot=True)
create_hex_grid(nx=50,
ny=50,
min_diam=1,
rotate_deg=5,
crop_circ=20,
do_plot=True,
h_ax=h_ax)
For API and additional examples see the wiki hexalattice API and assigning individual colors to hexagons.
Release History
- v1.0.0 - First version
- v1.1.0 - Added the option to assign different colors to hexagons
- v1.2.0 - Added control over the outer line width of the hexagons
- v1.2.2 - Added control over the axis background color
- v1.3.0 - Reduced runtime by 50%
About & License
Alex Kazakov ג€“ @bio_vs_silico ג€“ alex.kazakov@mail.huji.ac.il
Distributed under the MIT license. See LICENSE for more information.
Metadata
Release files for hexalattice 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hexalattice-1.3.0.tar.gz | 8.3 kB | Without provenance | Details for hexalattice-1.3.0.tar.gz |
Release files / hexalattice-1.3.0.tar.gz
| Download URL | hexalattice-1.3.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58acdc6da8aa13553d7155ca36b54f7572aba0f6e63436ed0391e5a9e5f28ce4
|
|
BLAKE2b-256 checksum How to use checksums |
b01aea7c7a8067cb01cda84a78a6cbfd83f972b1c7d050ce050bce38d2a9efc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|
Security for hexalattice 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.