plotnine.stats.stat_summary_bin¶
- class plotnine.stats.stat_summary_bin(mapping: Aes | None = None, data: DataLike | None = None, **kwargs: Any)[source]¶
Summarise y values at x intervals
Usage
stat_summary_bin(mapping=None, data=None, geom='pointrange', position='identity', na_rm=False, random_state=None, fun_ymin=None, fun_data=None, fun_y=None, binwidth=None, fun_args=None, bins=30, breaks=None, fun_ymax=None, boundary=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
'bin' # bin identifier 'width' # bin width 'ymin' # ymin computed by the summary function 'ymax' # ymax computed by the summary function
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.- binwidth
float
ortuple
, optional (default:None
) The width of the bins. The default is to use bins bins that cover the range of the data. You should always override this value, exploring multiple widths to find the best to illustrate the stories in your data.
- bins
int
ortuple
, optional (default: 30) Number of bins. Overridden by binwidth.
- breaksarray-like(
s
), optional (default:None
) Bin boundaries. This supercedes the
binwidth
,bins
andboundary
arguments.- boundary
float
ortuple
, optional (default:None
) A boundary between two bins. As with center, things are shifted when boundary is outside the range of the data. For example, to center on integers, use
width=1
andboundary=0.5
, even if 1 is outside the range of the data. At most one of center and boundary may be specified.- fun_data
str
orfunction
, optional One of
['mean_cl_boot', 'mean_cl_normal', 'mean_sdl', 'median_hilow', 'mean_se']
or any function that takes a array and returns a dataframe with three rows indexed asy
,ymin
andymax
. Defaults to'mean_se'
.- fun_y
function
, optional (default:None
) Any function that takes an array-like and returns a single value
- fun_ymax
function
, optional (default:None
) Any function that takes an array-like and returns a single 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
The binwidth, bins, breaks and bounary arguments can be a tuples with two values (
(xaxis-value, yaxis-value)
) of the required type.