plotnine.stats.stat_summary

class plotnine.stats.stat_summary(mapping=None, data=None, **kwargs)[source]

Calculate summary statistics depending on x

Usage

stat_summary(mapping=None, data=None, geom='pointrange', position='identity',
             na_rm=False, fun_ymin=None, random_state=None, fun_ymax=None,
             fun_args=None, fun_y=None, fun_data='mean_cl_boot', **kwargs)

Only the mapping and data can be positional, the rest must be keyword arguments. **kwargs can be aesthetics (or parameters) used by the geom.

Parameters
mappingaes, optional

Aesthetic mappings created with aes(). If specified and inherit.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

Calculated aesthetics are accessed using the stat function. e.g. 'stat(ymin)'.

datadataframe, optional

The data to be displayed in this layer. If None, the data from from the ggplot() call is used. If specified, it overrides the data from the ggplot() call.

geomstr 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.

positionstr 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. If True silently removes missing values.

fun_datastr or function, optional

One of ['mean_cl_boot', 'mean_cl_normal', 'mean_sdl', 'median_hilow'] or any function that takes a array and returns a dataframe with three columns named y, ymin and ymax. Defaults to 'mean_cl_boot'.

fun_yfunction, 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_ymaxfunction, optional (default: None)

Any function that takes an array-like and returns a value

fun_argsdict, 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_stateint or RandomState, optional

Seed or Random number generator to use. If None, then numpy global generator numpy.random is used.

Notes

If any of fun_y, fun_ymin or fun_ymax are provided, the value of fun_data will be ignored.