Skip to content
Processing squarify treemap layout algorithm
Branch: master
Clone or download
Latest commit 5d97623 Jun 7, 2019


Squarify is a Processing library that implements the squarify treemap layout algorithm. It divides an area into rectangles whose areas is sized based on a set of values, the rectangles being optimized to be as squary as possible.

This library is a translation in Java of an original Python algorithm made by Laserson. Based on algorithm from Bruls, Huizing, van Wijk, "Squarified Treemaps", but implements it differently.


Contributions Manager

Open up the Contributions Manager in the Processing IDE. Search for Squarify and install the library.

Manual Install

Go to the releases page of this repo and download the .zip file from there. Unzip it and move it into the libraries folder of your Processing sketches.


You can find a fully working example called UsingSquarify.pde in this repository.

ArrayList<SquarifiedRect> rects = s.getRects();

Instantiating a Squarify object with values and canvas geometry will give you access to a list of SquarifiedRect objects. These objects contain each rectangle geomtry data:

  • x is the top left x coordinate
  • y is the top left y coordinate
  • dx is the rectangle width
  • dy is the rectangle height

As a result, to draw a rectangle on your processing sketch, you can do:

SquarifiedRect r = rects.get(0);	// Draws first rect in the list
rect(r.getX(), r.getY(), r.getDx(), r.getDy());

UsingSquarify example output

Image of squarified output

You can’t perform that action at this time.