Control the color of Treemap

logo of a chart:Tree

This page aims to describe the customization you can apply on a treemap. You can easily plot a treemap and change the color of each group using the squarify library.

You can set the color of each group in a treemap using the color parameter:

#libraries
import matplotlib.pyplot as plt
import squarify # pip install squarify (algorithm for treemap)
 
# Change color
squarify.plot(sizes=[13,22,35,5], label=["group A", "group B", "group C", "group D"], color=["red","green","blue", "grey"], alpha=.4 )
plt.axis('off')
plt.show()

🚨 Grab the Data To Viz poster!


Do you know all the chart types? Do you know which one you should pick? I made a decision tree that answers those questions. You can download it for free!

    dataviz decision tree poster