Drawing hierarchical chart types

For a project I am currently working, I need to draw tree map, icicle and sunburst chart types.
I read about using matplotlib for this purpose. According to what I’ve read there is no direct way of drawing these chart types like calling a function.
I found out some open-source python packages using matplotlib to draw tree map and sunburst.

  1. squarify (GitHub - laserson/squarify: Pure Python implementation of the squarify treemap layout algorithm)
    This uses matplotlib.axes.Axes.bar (matplotlib.axes.Axes.bar — Matplotlib 3.5.2 documentation) to draw the tree map.

  2. sunburst (sunburst/plot.py at master · klieret/sunburst · GitHub)
    This uses matplotlib.patches.Wedge (matplotlib.patches.Wedge — Matplotlib 3.5.2 documentation) to draw the sunburst chart.

I couldn’t find a package for icicle. But it is similar to the tree map. I believe it would also be possible to draw icicle using a method similar to the tree map.

My question is, “Are these packages drawing those chart types in the best way ?”. I mean is there a better way to support chart types I’ve mentioned above ?

I am bit confused about using patches for drawing charts like sunburst. I feel like using patches for drawing a new chart type is not what patches are intended to be used.

Your help is appreciated. Thank you.

Perhaps link the chart types you are referring to? None of them are common in my field

Is there something in the docs that gives that impression? Patches are the basic graphic building blocks in matplotlib, and one of the things they’re most used for is to create chart types when there’s no plotting method.

A starburst chart looks like a nested pie chart, which is this example Nested pie charts — Matplotlib 3.5.2 documentation

And I think for the icicle chart, someone just asked how to make a flame chart on gitter and they look pretty similar? the advice given was that Broken Barh — Matplotlib 3.5.2 documentation should be a good starting point.


I was thinking patches are for drawing small graphics on top of a chart to express more. But now after going through the documentation again, I see patches help to extend the powers of matplotlib to new chart types if we want. Ex: drawing a chart type from scratch.

I looked at the resources you’ve pointed. They are providing a good starting point for me.

Thank you.