plotnine.stats.stat.stat¶
- class plotnine.stats.stat.stat(mapping: Aes | None = None, data: DataLike | None = None, **kwargs: Any)[source]¶
Base class of all stats
- static from_geom(geom: Geom) stat [source]¶
Return an instantiated stat object
stats should not override this method.
- classmethod aesthetics() set[str] [source]¶
Return a set of all non-computed aesthetics for this stat.
stats should not override this method.
- use_defaults(data: DataFrame) DataFrame [source]¶
Combine data with defaults and set aesthetics from parameters
stats should not override this method.
- setup_params(data: pd.DataFrame) dict[str, Any] [source]¶
Overide this to verify or adjust parameters
- setup_data(data: DataFrame) DataFrame [source]¶
Overide to modify data before compute_layer is called
- finish_layer(data: pd.DataFrame, params: dict[str, Any]) pd.DataFrame [source]¶
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.
stat computes and creates variables
variables mapped to aesthetics
stat sees and modifies data according to the aesthetic values
The default to is to do nothing.
- classmethod compute_layer(data: pd.DataFrame, params: dict[str, Any], layout: Layout) pd.DataFrame [source]¶
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:
- data
panda.DataFrame
Data points for all objects in a layer.
- params
dict
Stat parameters
- layout
plotnine.layout.Layout
Panel layout information
- data
- classmethod compute_panel(data: pd.DataFrame, scales: pos_scales, **params: Any)[source]¶
Calculate the statistics for all the groups
Return the results in a single dataframe.
This is a default function that can be overriden by individual stats
- Parameters:
- data
dataframe
data for the computing
- scales
dataclass
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:range_x = scales.x.dimension()
- params
dict
The parameters for the stat. It includes default values if user did not set a particular parameter.
- data
- classmethod compute_group(data: pd.DataFrame, scales: pos_scales, **params: Any) pd.DataFrame [source]¶
Calculate statistics for the group
All stats should implement this method
- Parameters:
- data
dataframe
Data for a group
- scales
types.SimpleNamespace
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:range_x = scales.x.dimension()
- params
dict
Parameters
- data