plotnine.stats.stat_sina¶
- class plotnine.stats.stat_sina(mapping: Aes | None = None, data: DataLike | None = None, **kwargs: Any)[source]¶
Compute Sina plot values
Usage
stat_sina(mapping=None, data=None, geom='sina', position='dodge', na_rm=False, random_state=None, maxwidth=None, bin_limit=1, binwidth=None, bw='nrd0', bins=None, method='density', adjust=1, scale='area', **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
'quantile' # quantile 'group' # group identifier
Calculated aesthetics are accessed using the after_stat function. e.g.
after_stat('quantile')
.- 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_sina
) 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_dodge
) 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
The width of the bins. The default is to use 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
(default: 50) Number of bins. Overridden by binwidth.
- method'density' or 'counts'
Choose the method to spread the samples within the same bin along the x-axis. Available methods: "density", "counts" (can be abbreviated, e.g. "d"). See Details.
- maxwidth
float
Control the maximum width the points can spread into. Values should be in the range (0, 1).
- adjust
float
, optional (default: 1) Adjusts the bandwidth of the density kernel when
method='density'
(see density).- bw
str
orfloat
, optional (default: 'nrd0') The bandwidth to use, If a float is given, it is the bandwidth. The
str
choices are:'nrd0' 'normal_reference' 'scott' 'silverman'
nrd0
is a port ofstats::bw.nrd0
in R; it is eqiuvalent tosilverman
when there is more than 1 value in a group.- bin_limit
int
(default: 1) If the samples within the same y-axis bin are more than bin_limit, the samples's X coordinates will be adjusted. This parameter is effective only when
method='counts'
- random_state
int
orRandomState
, optional Seed or Random number generator to use. If
None
, then numpy global generatornumpy.random
is used.- scale
str
(default:area
) How to scale the sina groups. The options are:
'area' # Scale by the largest density/bin amoung the different # sinas 'count' # areas are scaled proportionally to the number of points 'width' # Only scale according to the maxwidth parameter.
- mapping
See also