plotnine.stats.stat.stat
=None, data=None, kwargs={}) stat(mapping
Base class of all stats
Attributes
Name | Description |
---|---|
CREATES | set() -> new empty set object |
DEFAULT_AES | dict() -> new empty dictionary |
DEFAULT_PARAMS | dict() -> new empty dictionary |
NON_MISSING_AES | set() -> new empty set object |
REQUIRED_AES | set() -> new empty set object |
CREATES
set() -> new empty set object set(iterable) -> new set object
Build an unordered collection of unique elements.
DEFAULT_AES
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
DEFAULT_PARAMS
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
NON_MISSING_AES
set() -> new empty set object set(iterable) -> new set object
Build an unordered collection of unique elements.
REQUIRED_AES
set() -> new empty set object set(iterable) -> new set object
Build an unordered collection of unique elements.
Methods
Name | Description |
---|---|
aesthetics | Return a set of all non-computed aesthetics for this stat. |
compute_group | Calculate statistics for the group |
compute_layer | Calculate statistics for this layers |
compute_panel | Calculate the statistics for all the groups |
finish_layer | Modify data after the aesthetics have been mapped |
from_geom | Return an instantiated stat object |
setup_data | Override to modify data before compute_layer is called |
setup_params | Override this to verify or adjust parameters |
to_layer | Make a layer that represents this stat |
use_defaults | Combine data with defaults and set aesthetics from parameters |
aesthetics
aesthetics()
Return a set of all non-computed aesthetics for this stat.
stats should not override this method.
compute_group
={}) compute_group(data, scales, params
Calculate statistics for the group
All stats should implement this method
Parameters
compute_layer
compute_layer(data, params, layout)
Calculate statistics for this layers
This is the top-most computation method for the stat. It does not do any computations, but it knows how to verify the data, partition it call the next computation method and merge results.
stats should not override this method.
Parameters
compute_panel
={}) compute_panel(data, scales, params
Calculate the statistics for all the groups
Return the results in a single dataframe.
This is a default function that can be overridden by individual stats
Parameters
data : pd.DataFrame
-
data for the computing
scales : pos_scales
-
x (
scales.x
) and y (scales.y
) scale objects. The most likely reason to use scale information is to find out the physical size of a scale. e.g.= scales.x.dimension() range_x
params : Any = {}
-
The parameters for the stat. It includes default values if user did not set a particular parameter.
finish_layer
finish_layer(data, params)
Modify data after the aesthetics have been mapped
This can be used by stats that require access to the mapped values of the computed aesthetics, part 3 as shown below.
1. stat computes and creates variables
2. variables mapped to aesthetics
3. stat sees and modifies data according to the
aesthetic values
The default to is to do nothing.
Parameters
Returns
from_geom
from_geom(geom)
Return an instantiated stat object
stats should not override this method.
Parameters
geom : geom
-
A geom object
Returns
stat
-
A stat object
Raises
PlotnineError
if unable to create astat
.
setup_data
setup_data(data)
Override to modify data before compute_layer is called
Parameters
Returns
setup_params
setup_params(data)
Override this to verify or adjust parameters
Parameters
Returns
to_layer
to_layer()
Make a layer that represents this stat
Returns
out : layer
-
Layer
use_defaults
use_defaults(data)
Combine data with defaults and set aesthetics from parameters
stats should not override this method.