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.
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. |
| on_click | Callable[..., bool | None] | None | None | A callback function that is called when a point is clicked. The function receives a dict with 'points' (list of clicked point data) and 'modifiers' (keyboard state). On hierarchical charts (sunburst, treemap, icicle), return False to prevent drill-down. The return value is ignored on other chart types. |
| on_press | Callable[..., bool | None] | None | None | Alias for on_click. |
| on_double_click | Callable[..., None] | None | None | A callback function that is called on double-click. The function receives a dict with 'modifiers' (keyboard state). Fires in zoom/pan mode only; in select mode, on_deselect fires instead. |
| on_double_press | Callable[..., None] | None | None | Alias for on_double_click. |
| on_selected | Callable[..., None] | None | None | A callback function that is called when a box or lasso selection completes. The function receives a dict with 'points' (list of selected point data), 'range' (for box select), and 'modifiers'. |
| on_deselect | Callable[..., None] | None | None | A callback function that is called when the selection is cleared (e.g., by double-clicking on an empty area). |
| on_relayout | Callable[..., None] | None | None | A callback function that is called when the chart layout changes due to user interaction (pan, zoom, axis reset, etc.). The function receives a dict of the layout keys that changed. |
| on_legend_click | Callable[..., bool | None] | None | None | A callback function that is called when a legend item is clicked. Return False to prevent the default trace visibility toggle. Return True or None to allow it. |
| on_legend_double_click | Callable[..., bool | None] | None | None | A callback function that is called when a legend item is double-clicked. Return False to prevent the default isolate/show-all toggle. Return True or None to allow it. |
| on_click_annotation | Callable[..., None] | None | None | A callback function that is called when an annotation is clicked. The function receives a dict with 'index', 'annotation', and 'modifiers'. |
| on_web_gl_context_lost | Callable[..., None] | None | None | A callback function that is called when the WebGL rendering context is lost (e.g., GPU reclaims resources). |