explore_strip_plot

source

explore_strip_plot(
    df,
    by_var,
    var,
    *,
    time=None,
    order_by_mean=False,
    group_on_y=True,
    log=False,
    alpha=0.6,
    max_units=2000,
    sample_seed=0,
    entity=None,
    title=None,
    subtitle=None,
)

Strip plots of var across by_var groups, animated over time when available.

A jittered cloud of every observation within each group — complementary to :func:explore_box_plot, showing the raw points rather than a summary. On a panel each period becomes a frame with the value axis pinned; without a resolvable time id the clouds are static. Large samples are thinned to max_units points so the animation stays responsive.

Parameters

Name Type Description Default
df pd.DataFrame Data frame containing the grouping factor, the numeric variable and (optionally) a time column. required
by_var str Grouping column. required
var str Numeric variable whose observations are shown. required
time str | None Time identifier that drives the animation. Defaults to the panel time; when neither is available the clouds are static. None
order_by_mean bool If True, groups are ordered by descending group mean. False
group_on_y bool If True (default), groups are on the y-axis. True
log bool Put the value axis on a log scale (default False). False
alpha float Point opacity (default 0.6). 0.6
max_units int | None Cap on the number of plotted points; above it a seeded random sample is drawn and an :class:expdpy.ExpdpyWarning is emitted. None disables sampling. 2000
sample_seed int Seed for the point sample. 0
entity str | None Cross-sectional id (accepted for panel parity; only used to resolve the panel time). None

Returns

Name Type Description
StripPlotResult df (the complete-case frame plotted) and fig (the Plotly strip plot).

Examples

Every region’s inequality by continent, animated across the years:

import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def

df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
ex.explore_strip_plot(df, "continent", "gini_regional", time="year").fig