Utilities¶
Summary Helpers¶
get_summary_stats¶
- plotnine_extra.get_summary_stats(data, columns=None, type='common', groupvars=None)[source]¶
Compute summary statistics for one or more numeric columns.
- Parameters:
data (DataFrame) – Input data.
columns (str or list of str, optional) – Numeric columns to summarise. If
Noneall numeric columns are used.type (str, default
"common") – Profile of statistics. One of"common","robust","five_number","mean_sd","mean_se","mean_ci","median_iqr","median_mad","median_range","quantile"or"full".groupvars (str or list of str, optional) – Grouping columns. If supplied, the summary is computed within each group.
- Return type:
pd.DataFrame
desc_statby¶
add_summary¶
- plotnine_extra.add_summary(plot, fun='mean_se', error_plot='pointrange', color='black', fill='white', size=1.0, width=None, shape='o', linetype='solid', show_legend=False, **kwargs)[source]¶
Add a summary layer to an existing
ggplotobject.- Parameters:
plot (ggplot) – The plot to add the layer to.
fun (str or callable, default
"mean_se") – Either a name from the ggpubrfun.datafamily ("mean_se","mean_sd","mean_ci","median_iqr", …) or a callable returning a dict withy,yminandymax.error_plot (str, default
"pointrange") – Geom to use. One of"pointrange","linerange","crossbar","errorbar","upper_errorbar","lower_errorbar","upper_pointrange","lower_pointrange".color (str)
fill (str)
size (float)
width (float | None)
linetype (str)
show_legend (bool)
Summary Functions¶
mean_ci¶
mean_sd¶
mean_se¶
mean_range¶
median_iqr¶
median_mad¶
median_range¶
median_q1q3¶
median_hilow¶
- plotnine_extra.median_hilow_(x, conf_int=0.95)[source]¶
Return the median and percentile-based confidence bounds.
Matches ggpubr’s definition:
ymin = quantile(x, (1 - ci) / 2),ymax = quantile(x, (1 + ci) / 2).Note: this differs from
Hmisc::smedian.hilow, which uses an order-statistic interval. ggpubr deliberately uses the simpler percentile form; plotnine-extra follows suit.