Scale the Chart

Scale is used to change the range of the chart, by default, the range of the plot is 100×100. Using norm_x you can scale x-axis data whereas norm_y you can scale the y-axis. 

Python3




data = [100, 20, 50, 1000]
colors = ["red", "yellow", "blue", "green"]
squarify.plot(sizes=data, color=colors)


Output:

Scaling with both axes.

Python3




data = [100, 20, 50, 1000]
colors = ["red", "yellow", "blue", "green"]
squarify.plot(sizes=data, norm_x=1000
              norm_y=10, color=colors)


Output:

Treemaps in Python using Squarify

Data Visualization is a powerful technique to analyze a large dataset through graphical representation. Python provides various modules that support the graphical representation of data. The widely used modules are Matplotlib, Seaborn, and Plotly. And we have one more module named Squarify which is mainly used to plot a Treemap. 

Similar Reads

When To Use Squarify?

Here the question is when to use Squarify instead of Why to use. As Python already has 2 to 3 data visualization modules that do most of the task. Squarify is the best fit when you have to plot a Treemap. Treemaps display hierarchical data as a set of nested squares/rectangles-based visualization....

Plot Treemap Using Squarify

A Treemap diagram is an appropriate type of visualization when the data set is structured in hierarchical order with a tree layout with roots, branches, and nodes. It allows us to show information about an important amount of data in a very efficient way in a limited space....

Plot

...

Color

The plot is the method using which you can create a Treemap using Squarify. Squarify takes sizes as the first argument and also supports many features which we will look at one by one. Initially, the plot method plots a square of dimension 100×100....

Alpha

...

Scale the Chart

For making the plot more attractive we shall change the color of the plot. There are two ways by which we can change the color of the chart:...

Labels

...

Padding

...

Building A Treemap On Real-World Dataset Using Squarify

The alpha argument is used to vary the opacity of the image. It can either be an integer or floating value in the range of 0 to 1. The alpha value near 1 has high opacity whereas the alpha value near 0 has less opacity....