Skip to main content
Version: Python

plot_pie

The plot_pie method creates pie charts using data from Deephaven tables.

Syntax

plot_pie(
series_name: str,
t: Union[Table, SelectableDataSet],
category: Union[str, list[int], list[float]],
y: Union[str, list[int], list[float], list[DateTime]],
) -> Figure

Parameters

ParameterTypeDescription
series_namestr

The name (as a String) you want to use 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.

categoryUnion[str, list[str], list[int], list[float]]

The name of the column containing category values.

yUnion[str, list[int], list[float], list[DateTime]]

The name of the column containing discrete values.

Returns

A pie chart.

Examples

The following example plots data from a Deephaven table.

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

insurance = read_csv(
"https://media.githubusercontent.com/media/deephaven/examples/main/Insurance/csv/insurance.csv"
)
insurance_by_region = insurance.view(formulas=["region", "expenses"]).sum_by(["region"])

new_plot = (
Figure()
.plot_pie(
series_name="Insurance charges by region",
t=insurance_by_region,
category="region",
y="expenses",
)
.chart_title(title="Expenses per region")
.show()
)