# Space-Partitioning and Containment

They are used to represent hierarchical structures.

![](https://612062878-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RG_uqhxyMNjpMUW%2F-M5-0SvQ45Rarxg8L2lA%2F-M5-0V2I2QJsmNFp3lJy%2Fcontainment.png?generation=1586990822108202\&alt=media)

The largest rectangle represents the root node of the tree, and so on.

**Tree Maps** are the most commonly-used visualization that employ containment. The following shows how to generate a tree map from a simple tree:\
![](https://612062878-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RG_uqhxyMNjpMUW%2F-M5-0SvQ45Rarxg8L2lA%2F-M5-0V2Kvx9_jB6ovm_7%2Ftree%20to%20tree%20map.png?generation=1586990822176790\&alt=media)The areas in the resulting tree map are proportional to the node values.

**Area** can be used to encode quantity. **Color** can be used to encode both quantity (color intensity) and category (color hue). **Hierarchy** is used to encode structure/nesting.

![](https://612062878-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RG_uqhxyMNjpMUW%2F-M5-0SvQ45Rarxg8L2lA%2F-M5-0V2MWmLNK_-4xb70%2Ftreemap.png?generation=1586990822402393\&alt=media)

Here, hierarchy represents categories, color represents average profit, size represents the total number of sales.

**Tree Maps are extremely scalable**!

However, there is a key **issue** with the **slice and dice** method: when the rectangles have **different aspect ratios** (proportion of height vs. width), it becomes **difficult to compare areas**, especially with elongated rectangles.

To combat this issue, **squarified treemaps** were introduced. In a squarified treemap, the aim os to have the aspect ratio of each rectangle as close to 1 as possible (thereby making them squares), while still filling the entire chart area. This makes it much easier to compare areas.

**Voronoi Treemaps** split the areas in a more organic manner:\
![](https://612062878-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RG_uqhxyMNjpMUW%2F-M5-0SvQ45Rarxg8L2lA%2F-M5-0V2O7yunZEyjU7sh%2Fvoronoi.png?generation=1586990822358763\&alt=media)

Even **circular treemaps** exist:\
![](https://612062878-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5-0RG_uqhxyMNjpMUW%2F-M5-0SvQ45Rarxg8L2lA%2F-M5-0V2Qgnrw6HEiV6bH%2Fcircular%20treemap.png?generation=1586990822016047\&alt=media)

## Treemap Advantages

* Scalability
* Node visibility
* No overlapping marks, so less clutter
* Can encode size and color

## Treemap Disadvantages

* Cannot visualize structure directly
* Comparisons of rectangles with different aspect ratios is difficult (partially fixed by using squarified treemaps and other alternatives)
* Area isn't very effective as a metric for comparison, when compared to other metrics like position
