Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
The Data Visualization Workshop

You're reading from  The Data Visualization Workshop

Product type Book
Published in Jul 2020
Publisher Packt
ISBN-13 9781800568846
Pages 536 pages
Edition 1st Edition
Languages
Authors (2):
Mario Döbler Mario Döbler
Profile icon Mario Döbler
Tim Großmann Tim Großmann
Profile icon Tim Großmann
View More author details

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], \
    ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}