Search code examples
pythonmatplotlibplottreemap

How to edit the label font sizes on building a treemap with squarify in Python?


I am using a squarify package in python, codeLink, to draw a treemap, wikiTreemapArticle. Based on this example, I can produce a treemap, but I am unable to see how the fontsizes of the labels in the squares can be modified. The essential line in the script is:

ax = squarify.plot(countryPop, color=colors, label=labels, ax=ax, alpha=.7)

From here I cannot add the 'fontsize' attribute. How would I change the sizes of the labels?


Solution

  • Update: There is now a possibility to change the fontsize (squarify==0.3.0 or higher) via the text_kwargs parameter:

    ax = squarify.plot(countryPop, color=colors, label=labels, ax=ax, bar_kwargs={'alpha':.7}, text_kwargs={'fontsize':10})