Skip to content

Part-to-Whole Charts

Pie

src.dx.plotting.dex.basic_charts.pie(df, y, split_slices_by=None, show_total=True, pie_label_type='rim', pie_label_contents='name', return_view=False, **kwargs)

Generates a DEX pie plot from the given DataFrame.

Parameters:

Name Type Description Default
df

The DataFrame to plot.

required
y str

The column to use for the slice size.

required
split_slices_by Optional[str]

The column to use for splitting the slices. If not provided, slices will be split and sized by y.

None
show_total bool

Whether to show the total.

True
pie_label_type DEXPieLabelType

The pie label type to use: - "rim" (default) - "annotation" - "center" - "stem" - "none"

'rim'
pie_label_contents DEXPieLabelContents

The pie label contents to use: - "name" (default) - "value" - "percent" - "name_value" - "name_percent" - "value_percent"

'name'
return_view bool

Whether to return a DEXView object instead of render.

False
**kwargs

Additional keyword arguments to pass to the view metadata.

{}
Source code in src/dx/plotting/dex/basic_charts.py
def pie(
    df,
    y: str,
    split_slices_by: Optional[str] = None,
    show_total: bool = True,
    pie_label_type: options.DEXPieLabelType = "rim",
    pie_label_contents: options.DEXPieLabelContents = "name",
    return_view: bool = False,
    **kwargs,
) -> Optional[DEXPieChartView]:
    """
    Generates a DEX pie plot from the given DataFrame.

    Parameters
    ----------
    df: pd.DataFrame
        The DataFrame to plot.
    y: str
        The column to use for the slice size.
    split_slices_by: Optional[str]
        The column to use for splitting the slices. If not provided, slices will be split and sized by `y`.
    show_total: bool
        Whether to show the total.
    pie_label_type: DEXPieLabelType
        The pie label type to use:
            - `"rim"` (default)
            - `"annotation"`
            - `"center"`
            - `"stem"`
            - `"none"`
    pie_label_contents: DEXPieLabelContents
        The pie label contents to use:
            - `"name"` (default)
            - `"value"`
            - `"percent"`
            - `"name_value"`
            - `"name_percent"`
            - `"value_percent"`
    return_view: bool
        Whether to return a `DEXView` object instead of render.
    **kwargs
        Additional keyword arguments to pass to the view metadata.
    """
    if split_slices_by is None:
        split_slices_by = y
    raise_for_missing_columns([y, split_slices_by], df.columns)

    chart_settings = {
        "dim1": split_slices_by,
        "metric1": y,
        "show_total": show_total,
        "pie_label_type": pie_label_type,
        "pie_label_contents": pie_label_contents,
    }
    return handle_view(
        df,
        chart_mode="pie",
        chart=chart_settings,
        return_view=return_view,
        **kwargs,
    )

Donut

Coming soon!

Sunburst

Coming soon!

Treemap

Coming soon!

Partition

Coming soon!