plotnine.stats.stat_summary¶
- class plotnine.stats.stat_summary(mapping: Aes | None = None, data: DataLike | None = None, **kwargs: Any)[source]¶
Calculate summary statistics depending on x
Usage
stat_summary(mapping=None, data=None, geom='pointrange', position='identity', na_rm=False, random_state=None, fun_ymin=None, fun_data='mean_cl_boot', fun_y=None, fun_args=None, fun_ymax=None, **kwargs)
Only the
mapping
anddata
can be positional, the rest must be keyword arguments.**kwargs
can be aesthetics (or parameters) used by thegeom
.- Parameters:
- mapping
aes
, optional Aesthetic mappings created with
aes()
. If specified andinherit.aes=True
, it is combined with the default mapping for the plot. You must supply mapping if there is no plot mapping.Aesthetic
Default value
x
y
The bold aesthetics are required.
Options for computed aesthetics
'ymin' # ymin computed by the summary function 'ymax' # ymax computed by the summary function 'n' # Number of observations at a position
Calculated aesthetics are accessed using the after_stat function. e.g.
after_stat('ymin')
.- data
dataframe
, optional The data to be displayed in this layer. If
None
, the data from from theggplot()
call is used. If specified, it overrides the data from theggplot()
call.- geom
str
or geom, optional (default:geom_pointrange
) The statistical transformation to use on the data for this layer. If it is a string, it must be the registered and known to Plotnine.
- position
str
or position, optional (default:position_identity
) Position adjustment. If it is a string, it must be registered and known to Plotnine.
- na_rmbool, optional (default:
False
) If
False
, removes missing values with a warning. IfTrue
silently removes missing values.- fun_data
str
orfunction
, optional One of:
# Bootstrapped mean, confidence interval # Arguments: # n_samples - No. of samples to draw # confidence_interval # random_state 'mean_cl_boot' # Mean, C.I. assuming normal distribution # Arguments: # confidence_interval 'mean_cl_normal' # Mean, standard deviation * constant # Arguments: # mult - multiplication factor 'mean_sdl' # Median, outlier quantiles with equal tail areas # Arguments: # confidence_interval 'median_hilow' # Mean, Standard Errors * constant # Arguments: # mult - multiplication factor 'mean_se'
or any function that takes a array and returns a dataframe with three columns named
y
,ymin
andymax
. Defaults to'mean_cl_boot'
.- fun_y
function
, optional (default:None
) Any function that takes a array-like and returns a value fun_ymin : function (default:None) Any function that takes an array-like and returns a value
- fun_ymax
function
, optional (default:None
) Any function that takes an array-like and returns a value
- fun_args
dict
, optional (default:None
) Arguments to any of the functions. Provided the names of the arguments of the different functions are in not conflict, the arguments will be assigned to the right functions. If there is a conflict, create a wrapper function that resolves the ambiguity in the argument names.
- random_state
int
orRandomState
, optional Seed or Random number generator to use. If
None
, then numpy global generatornumpy.random
is used.
- mapping
See also
Notes
If any of
fun_y
,fun_ymin
orfun_ymax
are provided, the value offun_data
will be ignored.