packcircles
A pure Python implementation of the circle packing algorithm detailed in Wang et al. (2006). Visualization of large hierarchical data by circle packing. Proc of the SIGCHI, 517-520.
Installation
Using pip:
pip install packcircles
or directly using setup.py:
git clone https://github.com/mhtchan/packcircles.git
cd packcircles
python setup.py install
Usage
The function pack takes an iterable of the radii of the circles to pack and returns a generator that yields the layout of each circle as tuples in the form (x_coordinate, y_coordinate, radius).
Example
import packcircles as pc
circles = pc.pack([15,5,7,12])
print(list(circles))
## [(-15.579319782711305, 4.287939798231928, 15), (4.4206802172886945, 4.287939798231928, 5), (2.9206802172886945, -7.6179411015587295, 7), (20.647637933172685, -0.7801804930509242, 12)]
The layout in the gif at the top of the page can be generated by the following code:
import packcircles as pc
import matplotlib.pyplot as plt
from matplotlib.cm import get_cmap
radii = [28,12,51,26,10,16,24,25,59,11,29,40,16,11,10,26,39,16,48,36,28]
fig, ax = plt.subplots()
cmap = get_cmap('coolwarm_r')
circles = pc.pack(radii)
for (x,y,radius) in circles:
patch = plt.Circle(
(x,y),
radius,
color=cmap(radius/max(radii)),
alpha=0.65
)
ax.add_patch(patch)
fig.set_figheight(15)
fig.set_figwidth(15)
ax.set(xlim=(-150, 140), ylim=(-180, 170))
plt.axis('off')
Metadata
Release files for packcircles 0.14
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 |
|---|---|---|---|---|
| packcircles-0.14.tar.gz | 4.1 kB | Without provenance | Details for packcircles-0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| packcircles-0.14-py3-none-any.whl | Python 3 | none | any | Details for packcircles-0.14-py3-none-any.whl |
Total release size: 9.2 kB
Release files / packcircles-0.14.tar.gz
| Download URL | packcircles-0.14.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13e9cc8978886b21faa19648b61b8c45fbca055c084b35347892bcb76d0b5083
|
|
BLAKE2b-256 checksum How to use checksums |
db460dbdefe27b67b6ccf86bdf6daa2efa5ec047aab24714d6f9b7b9269e4f88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
|
Release files / packcircles-0.14-py3-none-any.whl
| Download URL | packcircles-0.14-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b58511187c7beb9ffacc750eff6a87b0dbfbc5e8d88f8d9fb632d7f2a96ad8d1
|
|
BLAKE2b-256 checksum How to use checksums |
e30c1147e896cab9a53cf1c3a213f274db6ea9997d4681cb975f5cf701b00988
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
|
Security for packcircles 0.14
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.