# libraries import matplotlib.pyplot as plt import squarify # pip install squarify (algorithm for treemap) import pandas as pd # Create a data frame with fake data df = pd.DataFrame({'nb_people':[8,3,4,2], 'group':["group A", "group B", "group C", "group D"] }) # plot it squarify.plot(sizes=df['nb_people'], label=df['group'], alpha=.8 ) plt.axis('off') # plt.show() path = '../img/' filename = 'filename.png' saved = path + filename plt.savefig(saved, dpi = 300)