skillfed

squarify

Pure Python implementation of the squarify treemap layout algorithm

squarify v0.4.4 279.7K downloads/30d#8,118 on PyPI333
Permissive license Apache License 2.0 AGING released

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 squarify

uv

uv add squarify

poetry

poetry add squarify

Installing 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

Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

treemap layout algorithmsquarified treemaprectangle packing visualizationhierarchical data layouttreemap coordinate computationdata visualization rectanglessquarify algorithm
treemap-layoutdata-visualizationalgorithm

More Graphics packages