Skip to main content
Version: Python

plot_treemap

The plot_treemap method creates treemap charts using data from Deephaven tables.

Syntax

plot_treemap(
series_name: str,
t: Union[Table, SelectableDataSet],
id: str,
parent: str,
label: str = None,
value: str = None,
hover_text: str = None,
color: str = None,
) -> tree map

Parameters

ParameterTypeDescription
series_namestr

The name (as a String) to identify the series on the plot itself.

tUnion[Table, SelectableDataSet]

The table (or other selectable data set) that holds the data to be plotted.

idstr

The name of the column containing ID values.

parentstr

The name of the column containing parent ID values.

label optionalstr

The name of the column containing labels. If not provided, labels default to the ID value.

value optionalstr

The name of the column containing values for how large each section in relation to other sections.

hover_text optionalstr

The name of the column containing hover text shown when hovering over a section in the treemap.

color optionalstr

The name of the column containing hexadecimal color to use for each section.

Returns

A treemap chart.

Examples

The following example plots data from a Deephaven table.

from deephaven import read_csv
from deephaven.plot.figure import Figure

# source the data
source = read_csv("https://media.githubusercontent.com/media/deephaven/examples/main/StandardAndPoors500Financials/csv/s_and_p_500_market_cap.csv")

# plot the data
s_and_p = Figure().plot_treemap(series_name = "S&P 500 Companies by Sector", t = source, id = "Label", parent = "Parent").show()

In the following example, plot_treemap is used to plot data from a Deephaven table, including the optional label, value, hover_text, and color parameters.

from deephaven import read_csv
from deephaven.plot.figure import Figure

# source the data
source = read_csv("https://media.githubusercontent.com/media/deephaven/examples/main/StandardAndPoors500Financials/csv/s_and_p_500_market_cap.csv")

# plot the data
s_and_p_marketcap = Figure().plot_treemap(series_name = "S&P 500 Market Cap", t = source, id = "Label", parent = "Parent", label = "Label", value = "Value", hover_text = "HoverText", color = "Color").show()