Squarify
At this point, we will briefly talk about tree maps. Tree maps display hierarchical data as a set of nested rectangles. Each group is represented by a rectangle, of which its area is proportional to its value. Using color schemes, it is possible to represent hierarchies (groups, subgroups, and so on). Compared to pie charts, tree maps use space efficiently. Matplotlib and Seaborn do not offer tree maps, and so the Squarify library that is built on top of Matplotlib is used. Seaborn is a great addition for creating color palettes.
Note
To install Squarify, first launch the command prompt from the Anaconda Navigator. Then, execute the following command: pip install squarify
.
The following code snippet is a basic tree map example. It requires the squarify
library:
%matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import squarify colors = sns.light_palette("brown", 4) squarify.plot(sizes=[50, 25, 10, 15], \ ...