john's Avatar


27 Nov, 2017 01:11 AM

Treemaps are a great way to visualize relative proportions within a hierarchy. Most Treemap algorithms require recursion so are hard to do entirely within NodeBox. I implemented this version using a custom node.

The treemap subnetwork takes a list of values and a bounding rectangle. It outputs the rectangles which comprise the treetop. The rectangles are colored but you will generally want to re-color them to express categories or some other dimension like intensity.

The list of values can be unordered and unnormalized, but will be sorted in descending order to create the treemap. Therefor you will generally want to sort them in descending order yourself beforehand so that you can correlate them to associated information like labels.

The attached demo shows two examples. The first, consisting of only three nodes, plots a set of random numbers. Adjust the number of random values and the size of the rectangle to see how the treemap adapts.

The second example shows how to make a compound colored treemap with labels and a legend. The top-level treemap shows the relative proportion of instruments in four stages of the evolution of orchestras. Those four rectangles are colored with a thicker border. The rectangles are then fed into another treemap subnet so that each is further subdivided. I also provide a labels subnet that automatically sizes each minor box label, rotating when necessary.

Inside the treemap subnet is the make_map custom node which does the actual work, using the squarify algorithm. You will need to add the file to your code library whenever using this node. If you want thicker borders around a top level treemap you can change the function call (in the node's Metadata under Settings) from treemap/squarify to treemap/padded_squarify.

If you make anything interesting with this subnet please share it on the forum. Enjoy!


  1. Support Staff 1 Posted by john on 27 Dec, 2017 07:25 AM

    john's Avatar

    Could someone please try downloading this demo and see if it works?

    A fellow Nodeboxer keeps getting an error which prevents him from opening the demo network, but when I try it, it seems fine. If someone else could try it we could figure out whether the problem is at my end or his.



  2. Support Staff 2 Posted by lucasnijs on 27 Dec, 2017 08:58 AM

    lucasnijs's Avatar

    Hello John,

    works fine with me.
    Is he using 3.0.50? Else the make_table node will not exist and cause an error.
    What error does he get?


    best wishes for 2018!


  3. Support Staff 3 Posted by john on 27 Dec, 2017 11:52 PM

    john's Avatar

    Thanks, Lucas.

    Your hunch was correct. He was getting an error about make_table and apparently had not downloaded 3.0.50.

    Glad to hear that my custom node is working OK. Best wishes back to you and everyone at NodeBox central.


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • Treemap_Screenshot.png 474 KB
  • 6.91 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

22 Jan, 2019 12:41 AM
19 Jan, 2019 07:11 PM
18 Jan, 2019 12:54 AM
09 Jan, 2019 07:23 PM
02 Jan, 2019 12:03 AM


31 Dec, 2018 02:49 PM
30 Dec, 2018 07:20 AM
28 Dec, 2018 05:50 PM
28 Dec, 2018 01:34 AM
27 Dec, 2018 09:38 PM
10 Dec, 2018 01:47 PM