squarify
Pure Python implementation of the squarify treemap layout algorithm
What it is and what it does
Squarify is a pure Python implementation of the squarified treemap layout algorithm based on the academic work by Bruls, Huizing, and van Wijk. It takes a list of numeric values and a rectangular coordinate space, then computes the positions and dimensions of rectangles whose areas are proportional to the input values. The algorithm aims to produce rectangles with aspect ratios close to square, making treemaps more readable than naive approaches.
The package provides three main functions: squarify() for basic rectangle computation, padded_squarify() for adding visual gaps between rectangles, and a plot() helper that generates Matplotlib-based visualizations. It also includes normalize_sizes() to scale input values to match the target area. The output is a list of dictionaries, each containing x, y, dx, and dy coordinates suitable for rendering with visualization libraries or custom applications.
Use it for:
- Generate treemap layouts for visualizing hierarchical data like file system sizes or organizational structures.
- Compute rectangle coordinates for custom rendering in web-based visualization frameworks.
- Create Matplotlib-based treemap plots with optional padding and custom colors for exploratory data analysis.
- Normalize and layout data values to fit within a bounded rectangular space for dashboard displays.
- Build interactive treemap visualizations by obtaining rectangle coordinates for further processing.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Computes treemap layout rectangles from a list of values using the squarified algorithm, suitable for visualizing hierarchical data as nested rectangles.
Yes, if you need treemap layout computation. The package has no dependencies, installs easily, and solves a specific algorithmic problem well. The aging maintenance status is not a blocker for a stable, narrow-scope algorithm library, but verify that the implementation meets your precision or performance requirements before adopting it in production.
Install
squarify on PyPI
pip
pip install squarifyuv
uv add squarifypoetry
poetry add squarifyInstalling squarify
Before you install
Low install friction with no runtime dependencies. Maintenance is aging—last release was 2024-07-19, and the repository remains active and unarchived.
License in practice
Licensed under Apache License 2.0, a permissive license that allows commercial and private use with minimal restrictions.
Quickstart
import squarify
values = [500, 433, 78, 25, 25, 7]
values = squarify.normalize_sizes(values, 700, 433)
rects = squarify.squarify(values, 0, 0, 700, 433)
Verify before relying
- Whether the package works with Python versions older than 3.8 despite the description mentioning Python 2 compatibility.
- Whether Matplotlib is required for all use cases or only when using the plot() helper function.
- Performance characteristics and numerical precision of the implementation for large datasets.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 756 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 279,662/month — #8,118 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: squarify-0.4.4-py3-none-any.whl
Keywords: treemap, visualization, squarify, layout, graphics
Tags
More Graphics packages
Pillow adds image processing capabilities to…
permissive · top 100 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
matplotlib-inlineEnables matplotlib figures to display inline…
permissive · top 1,000 on PyPI
pymupdfPyMuPDF extracts, renders, converts, and…
agpl · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI
altairAltair is a declarative Python library for…
permissive · top 1,000 on PyPI
rectpackRectpack solves the 2D bin packing problem by…
permissive · top 15,000 on PyPI
rectangle-packerPacks a set of rectangles with fixed…
permissive · top 15,000 on PyPI
PyRectPyRect provides a Rect class for representing…
permissive · top 5,000 on PyPI
grandalfGrandalf computes node coordinates and routes…
copyleft · top 5,000 on PyPI
shapely-polyskelComputes the straight skeleton of a polygon, a…
copyleft · top 15,000 on PyPI
pixelhogCompares PNG screenshots pixel-by-pixel and…
permissive · top 5,000 on PyPI
qrdetDetects and segments QR codes in images using a…
permissive · top 15,000 on PyPI
pdfplumberExtract detailed information about text…
permissive · top 1,000 on PyPI
py3dbpSolves the 3D bin packing problem by fitting…
permissive · top 5,000 on PyPI
treelibProvides a simple tree data structure…
permissive · top 5,000 on PyPI