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_trend_plot(df, var=["log_gdp_pc"]).figexplore_trend_plot
explore_trend_plot(
df,
var=None,
*,
time=None,
entity=None,
spaghetti=False,
title=None,
subtitle=None,
)Line-plot the mean (with standard-error bars) of variables over time.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Data frame containing time and the numeric variables to plot. |
required |
| var | Sequence[str] | None | Variables to plot. Defaults to all numeric columns other than time/entity. |
None |
| time | str | None | Column name of the time identifier. Defaults to the panel time declared via :func:expdpy.set_panel. |
None |
| entity | str | None | Column name of the cross-sectional (unit) identifier. Only used when spaghetti=True. Defaults to the panel entity declared via :func:expdpy.set_panel. |
None |
| spaghetti | bool | If True (and a single var and an entity are available), draw a faint per-unit trajectory backdrop behind the mean line. For richer per-unit views see :func:expdpy.explore_spaghetti_plot. |
False |
Returns
| Name | Type | Description |
|---|---|---|
| TrendGraphResult | df (columns variable, time, mean, se) and the Plotly fig. |
Examples
Basic — mean of a single variable over time, with standard-error bars:
Advanced — several variables on one chart, with the aggregated frame from .df:
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)
result = ex.explore_trend_plot(df, var=["log_gdp_pc", "trade_share"])
result.fig
result.df.head()| variable | year | mean | se | |
|---|---|---|---|---|
| 0 | log_gdp_pc | 2015 | 9.077922 | 0.167032 |
| 1 | log_gdp_pc | 2016 | 9.105304 | 0.165961 |
| 2 | log_gdp_pc | 2017 | 9.132692 | 0.165664 |
| 3 | log_gdp_pc | 2018 | 9.148910 | 0.165501 |
| 4 | log_gdp_pc | 2019 | 9.180302 | 0.165741 |