Pie Plot

A pie plot is a circular data visualization that illustrates the relative proportions of discrete categories within a dataset by dividing a circle into sectors. This format provides a quick and straightforward way to convey the composition of data.

Pie plots are appropriate when the data contain a categorical variable where the frequencies of each category can be computed.

What are pie plots useful for?

  • Proportional representation: Pie plots effectively convey the proportional distribution of categories, making them useful when you want to highlight the relative size of discrete components within a whole.
  • Simplicity: Pie plots are straightforward to interpret and can be especially valuable when communicating data to non-technical audiences, as they provide an easily digestible overview of data composition.

Pie plots do have some limitations. They become less effective when dealing with a large number of categories, as it can be challenging to differentiate and interpret small slices, leading to cluttered and less informative visualizations. Consider using a bar plot instead.

Examples

A basic pie plot

Visualize the contribution of each part to the whole, arranged clockwise from greatest to least contribution. Pass the label column name to the names argument, and the value column name to the values argument.

import deephaven.plot.express as dx
gapminder = dx.data.gapminder()

# get table of most recent total population per continent
gapminder_recent_pop = (
    gapminder
    .last_by("Country")
    .drop_columns(["Country", "LifeExp", "GdpPerCap"])
    .sum_by(["Year", "Month", "Continent"])
)

pie_plot = dx.pie(gapminder_recent_pop, names="Continent", values="Pop")

API Reference

Returns a pie chart

Returns: DeephavenFigure A DeephavenFigure that contains the pie chart

ParametersTypeDefaultDescription
tableTable |
DataFrame
A table to pull data from.
namesstr |
None
NoneThe column containing names of the pie slices
valuesstr |
None
NoneThe column containing values of the pie slices
colorstr |
list[str] |
None
NoneA column or list of columns that contain color values. The value is used for a plot by on color. See color_discrete_map for additional behaviors.
hover_namestr |
None
NoneA column that contain names to bold in the hover tooltip..
labelsdict[str, str] |
None
NoneA dictionary of labels mapping columns to new labels.
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, 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.
titlestr |
None
NoneThe title of the chart
templatestr |
None
NoneThe template for the chart.
opacityfloat |
None
NoneOpacity to apply to all markers. 0 is completely transparent and 1 is completely opaque.
holefloat |
None
NoneFraction of the radius to cut out of the center of the pie.
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.