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
Parameters | Type | Default | Description |
---|---|---|---|
table | Table | DataFrame | A table to pull data from. | |
names | str | None | None | The column containing names of the pie slices |
values | str | None | None | The column containing values of the pie slices |
color | str | list[str] | None | None | A 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_name | str | None | None | A column that contain names to bold in the hover tooltip.. |
labels | dict[str, str] | None | None | A dictionary of labels mapping columns to new labels. |
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, 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. |
title | str | None | None | The title of the chart |
template | str | None | None | The template for the chart. |
opacity | float | None | None | Opacity to apply to all markers. 0 is completely transparent and 1 is completely opaque. |
hole | float | None | None | Fraction of the radius to cut out of the center of the pie. |
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. |