prepare_quantile_trend_graph
prepare_quantile_trend_graph(
df,
ts_id,
quantiles=(0.05, 0.25, 0.5, 0.75, 0.95),
var=None,
*,
points=True,
)Line-plot quantiles of a single variable over time.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Data frame containing ts_id and the variable to plot. |
required |
| ts_id | str | Column name of the time-series identifier. | required |
| quantiles | Sequence[float] | Quantile levels to plot (each in (0, 1)). |
(0.05, 0.25, 0.5, 0.75, 0.95) |
| var | str | None | Variable to plot. Defaults to the last numeric column that is not ts_id. |
None |
| points | bool | Whether to mark each observation with a point. | True |
Returns
| Name | Type | Description |
|---|---|---|
| QuantileTrendGraphResult | df (long format: ts_id, quantile, value) and the Plotly fig. |
Examples
Basic — the default quantiles of a variable over time:
import expdpy as ex
from expdpy.data import load_kuznets
df = load_kuznets()
ex.prepare_quantile_trend_graph(df, ts_id="year", var="gini_regional").figAdvanced — custom quantile levels and no per-observation points:
ex.prepare_quantile_trend_graph(
df, ts_id="year", var="gini_regional", quantiles=(0.1, 0.5, 0.9), points=False
).fig