Treemaps
When to use a Treemap
A Treemap is a visualization of hierarchical structures. It is very effective in showing attributes of leaf nodes using size and color coding. Treemaps enable users to compare nodes and sub-trees even at varying depth in the tree, and help them spot patterns and exceptions.
How treemaps work
Many data sets have a hierarchical structure: items are divided into categories, subcategories, and so on. For example, a set of statistics on foods might include not just the food name ("Grapefruit") but a column for general type ("Fruit") and subtype ("Citrus"). A treemap uses this category information to create a kind of map of the data set.
Each data item, or row in the data set, is represented by a rectangle. The rectangles have different sizes, with the area being proportional to a user-defined attribute. For instance, in the example above, the area might correspond to overall sales of an item in a grocery store. Because areas can't be negative, it's best not to have the area of rectangles reflect a column with negative values. If your data does have negative values in the area column, they will be ignored.
The rectangles are colored to reflect other attributes of the data set. In Many Eyes we provide two types of treemap: a "plain" Treemap, and a special Change Treemap. In the plain version, a user can define a particular column of a data set to correspond to color. In the example above, color might show profit margin on a particular food item. A Change Treemap is designed to show changes or other comparisons: the user is given two menus to select two different numeric columns. The second column determines the area of items on the map, and the color reflects the percent difference between the first and second column. If your data set includes numbers such as yearly sales, this is a convenient way to visualize change over time.
A treemap requires a somewhat complex data table. To create the categories and subcategories, Many Eyes will look at all the text columns, in order from left to right. The leftmost text column will be used for the highest-level category, the next for the level below that, and so on.
An example data set suitable for a treemap is:
| Type | Food | Sales | Profit Margin |
|---|---|---|---|
| Fruit | Banana | 1456 | 12 |
| Fruit | Lemon | 23 | -6 |
| Fruit | Orange | 981 | 12 |
| Meat | Pork | 111 | 2 |
| Meat | Beef | 442 | 6 |
| Meat | Chicken | 1456 | 77 |
This table would be appropriate for a plain treemap. In this table, "Type" and "Food" would be used as category information to construct the map. It would make sense to map Sales to area, and Profit Margin to color.