Sunburst Plot

Sunburst plots are a data visualization technique used to represent hierarchical data with a radial layout. They display data as nested rings or sectors, where each level of the hierarchy is represented by a ring, and each category or subcategory is shown as a sector within the ring. Sunburst plots provide an effective way to visualize hierarchical data structures and the relationships between different levels and categories within the data, making them a valuable tool for understanding complex data hierarchies.

Sunburst 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 sunburst plots useful for?

  • Hierarchical Data Visualization: Sunburst plots are valuable for visualizing hierarchical data structures, making them suitable for applications where data has multiple levels of nested categories or relationships. Developers can use sunburst plots to represent data in a manner that clearly illustrates the hierarchical organization of information.
  • Tree Maps Replacement: Sunburst plots can be an alternative to tree maps for visualizing hierarchical data. Developers can use sunburst plots to present hierarchical data in a space-efficient and visually appealing manner. This can be particularly beneficial in applications where screen real estate is limited, and users need to view hierarchical data with an interactive and intuitive interface.
  • Drill-Down Data Exploration: Developers can implement sunburst plots for drill-down data exploration, allowing users to interactively explore and delve deeper into hierarchical data by clicking on sectors to reveal lower-level categories or information. This use case is valuable in applications that require detailed hierarchical data analysis.

Examples

A basic sunburst plot

Visualize a hierarchical dataset as concentric circles, with the size of each group decreasing in a counter-clockwise fashion. 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`")
)

sunburst_plot = dx.sunburst(gapminder_recent, names="Continent", values="Pop", parents="World")

API Reference

Returns a sunburst chart

Returns: DeephavenFigure A DeephavenFigure that contains the sunburst chart

ParametersTypeDefaultDescription
tableTable |
DataFrame
A table to pull data from.
namesstr |
None
NoneThe column containing names of the sections
valuesstr |
None
NoneThe column containing values of the sections
parentsstr |
None
NoneThe column containing parents of the sections
idsstr |
None
NoneThe column containing ids of the sections. Unlike values, these must be unique. Values are used for ids if ids are not specified.
colorstr |
list[str] |
None
NoneA 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.
hover_namestr |
None
NoneA column that contains names to bold in the hover tooltip.
color_discrete_sequencelist[str] |
None
NoneA 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_mapdict[str | tuple[str], str] |
None
NoneIf dict, the keys should be strings of the column values (or a tuple of combinations of column values) which map to colors.
color_continuous_scalelist[str] |
None
NoneA list of colors for a continuous scale
range_colorlist[float] |
None
NoneA list of two numbers that form the endpoints of the color axis
color_continuous_midpointfloat |
None
NoneA number that is the midpoint of the color axis
labelsdict[str, str] |
None
NoneA dictionary of labels mapping columns to new labels.
titlestr |
None
NoneThe title of the chart
templatestr |
None
NoneThe template for the chart.
branchvaluesstr |
None
NoneSet 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.
maxdepthint |
None
NoneSets the total number of visible levels. Set to -1 to render all levels.
unsafe_update_figureCallable<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.