Icicle Plot
Icicle plots, a hierarchical data visualization technique, are used to represent structured data with nested categories or levels. They are characterized by a rectangular layout where each column represents a level of the hierarchy, and the width of each subcolumn is proportional to the quantity of data within its respective category, facilitating the visualization of data structure and distribution.
Icicle plots are appropriate when the data have a hierarchical structure. Each level of the hierarchy consists of a categorical variable and an associated numeric variable with a value for each unique category.
What are icicle plots useful for?
- Representing hierarchical data: Icicle charts are particularly useful for visualizing hierarchical data, such as organizational structures, file directories, or nested categorical data. They provide a clear and intuitive way to represent multiple levels of hierarchy in a single view.
- Space-efficient plotting: By using a compact rectangular layout, icicle charts make efficient use of space. This allows for the display of large and complex hierarchies without requiring extensive scrolling or panning, making it easier to analyze and interpret the data at a glance.
- Comparative analysis: The consistent and proportional layout of icicle charts makes them effective for comparing the size and structure of different branches within the hierarchy. Users can easily identify and compare the relative importance or size of various categories, facilitating better decision-making and resource allocation.
Examples
A basic icicle plot
Visualize a hierarchical dataset as nested rectangles, with categories displayed left-to-right, and the size of each category displayed top-to-bottom. Use the names
argument to specify the column name for each group’s labels, the values
argument to specify the column name for each group’s values, and the parents
column to specify the root category of the chart.
import deephaven.plot.express as dx
gapminder = dx.data.gapminder()
# create table of only the most recent year of data, compute total population for each continent
gapminder_recent = (
gapminder
.last_by("Country")
.view(["Continent", "Pop"])
.sum_by("Continent")
.update("World = `World`")
)
icicle_plot = dx.icicle(gapminder_recent, names="Continent", values="Pop", parents="World")
API Reference
Returns a icicle chart
Returns: DeephavenFigure
A DeephavenFigure that contains the icicle chart
Parameters | Type | Default | Description |
---|---|---|---|
table | Table | DataFrame | A table to pull data from. | |
names | str | None | None | The column containing names of the sections |
values | str | None | None | The column containing values of the sections |
parents | str | None | None | The column containing parents of the sections |
color | str | list[str] | None | None | A column or list of columns that contain color values. If only one column is passed, and it contains numeric values, the value is used as a value on a continuous color scale. Otherwise, the value is used for a plot by on color. See color_discrete_map for additional behaviors. |
ids | str | None | None | The column containing ids of the sections. Unlike values, these must be unique. Values are used for ids if ids are not specified. |
hover_name | str | None | None | A column that contains names to bold in the hover tooltip. |
color_discrete_sequence | list[str] | None | None | A list of colors to sequentially apply to the series. The colors loop, so if there are more series than colors, colors will be reused. |
color_discrete_map | dict[str | tuple[str], str] | None | None | If dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to colors. |
color_continuous_scale | list[str] | None | None | A list of colors for a continuous scale |
range_color | list[float] | None | None | A list of two numbers that form the endpoints of the color axis |
color_continuous_midpoint | float | None | None | A number that is the midpoint of the color axis |
labels | dict[str, str] | None | None | A dictionary of labels mapping columns to new labels. |
title | str | None | None | The title of the chart |
template | str | None | None | The template for the chart. |
branchvalues | str | None | None | Set to 'total' to take the value at a level to include all descendants and 'remainder' to the value as the remainder after subtracting leaf values. |
maxdepth | int | None | None | Sets the total number of visible levels. Set to -1 to render all levels. |
unsafe_update_figure | Callable | <function default_callback> | An update function that takes a plotly figure as an argument and optionally returns a plotly figure. If a figure is not returned, the plotly figure passed will be assumed to be the return value. Used to add any custom changes to the underlying plotly figure. Note that the existing data traces should not be removed. This may lead to unexpected behavior if traces are modified in a way that break data mappings. |