This blog is part of Matplotlib Series:
- Matplotlib Series 1: Bar chart
- Matplotlib Series 2: Line chart
- Matplotlib Series 3: Pie chart
- Matplotlib Series 4: Scatter plot
- Matplotlib Series 5: Treemap (this blog)
- Matplotlib Series 6: Venn diagram
- Matplotlib Series 7: Area chart
- Matplotlib Series 8: Radar chart
- Matplotlib Series 9: Word cloud
- Matplotlib Series 10: Lollipop plot
- Matplotlib Series 11: Histogram
Treemap
Treemaps display hierarchical (tree-structured) data as a set of nested rectangles. Each branch of the tree is given a rectangle, which is then tiled with smaller rectangles representing sub-branches. A leaf node’s rectangle has an area proportional to a specified dimension of the data. Often the leaf nodes are colored to show a separate dimension of the data.
When to use it ?
- Less than 10 branches
- Positive values
- Space for visualisation is limited.
Example
This treemap describes volume for each product universe with corresponding surface. Liquid products are more sold than others. If you want to explore more, we can go into products “liquid” and find which shelves are prefered by clients.
Counter-example
This example shows the reason why a treemap should have less than 10 branches. In the plot above, there are 11 branches, and at the top right corner, the surface for branches “Salad” and “Shampooing” is too small to display the information clearly. Thus, a treemap whth less than 10 branches is a better choice.
You can click here to check this example in jupyter notebook.
Reference
- Steve Johnson, “painting wallpaper”, www.pexels.com. [Online]. Available: https://www.pexels.com/photo/painting-wallpaper-1070527/