plotnine.facets.facet.facet¶
- class plotnine.facets.facet.facet(scales: Literal['fixed', 'free', 'free_x', 'free_y'] = 'fixed', shrink: bool = True, labeller: Literal['label_value', 'label_both', 'label_context'] = 'label_value', as_table: bool = True, drop: bool = True, dir: Literal['h', 'v'] = 'h')[source]¶
Base class for all facets
- Parameters
- scales
python:str
in
['fixed', 'free', 'free_x', 'free_y']
Whether
x
ory
scales should be allowed (free) to vary according to the data along the rows or the columns. Default is'fixed'
.- shrinkbool
Whether to shrink the scales to the output of the statistics instead of the raw data. Default is
True
.- labeller
python:str
|function
How to label the facets. If it is a
str
, it should be one of'label_value'
'label_both'
or'label_context'
. Default is'label_value'
- as_tablebool
If
True
, the facets are laid out like a table with the highest values at the bottom-right. IfFalse
the facets are laid out like a plot with the highest value a the top-right. Default itTrue
.- dropbool
If
True
, all factor levels not used in the data will automatically be dropped. IfFalse
, all factor levels will be shown, regardless of whether or not they appear in the data. Default isTrue
.- dir
python:str
in
['h', 'v']
Direction in which to layout the panels.
h
for horizontal andv
for vertical.
- scales
- ncol: int¶
number of columns
- nrow: int¶
number of rows
- params: dict[str, Any]¶
A dict of parameters created depending on the data (Intended for extensions)
- free: dict[Literal['x', 'y'], bool]¶
Which axis scales are free
- setup_data(data: list[pandas.core.frame.DataFrame]) list[pandas.core.frame.DataFrame] [source]¶
Allow the facet to manipulate the data
- Parameters
- data
python:list
of
dataframes
Data for each of the layers
- data
- Returns
- data
python:list
of
dataframes
Data for each of the layers
- data
Notes
This method will be called after
setup_params()
, therefore the params property will be set.
- setup_params(data: list[pandas.core.frame.DataFrame])[source]¶
Create facet parameters
- Parameters
- data
python:list
of
dataframes
Plot data and data for the layers
- data
- map(data: DataFrame, layout: DataFrame) DataFrame [source]¶
Assign a data points to panels
- Parameters
- data
DataFrame
Data for a layer
- layout
DataFrame
As returned by self.compute_layout
- data
- Returns
- data
DataFrame
Data with all points mapped to the panels on which they will be plotted.
- data
- compute_layout(data: list[pandas.core.frame.DataFrame]) DataFrame [source]¶
Compute layout
- Parameters
- data
Dataframes
Dataframe for a each layer
- data
- finish_data(data: pd.DataFrame, layout: Layout) pd.DataFrame [source]¶
Modify data before it is drawn out by the geom
The default is to return the data without modification. Subclasses should override this method as the require.
- Parameters
- data
DataFrame
A single layer's data.
- layout
Layout
Layout
- data
- Returns
- data
DataFrame
Modified layer data
- data
- train_position_scales(layout: Layout, layers: Layers) facet [source]¶
Compute ranges for the x and y scales
- make_ax_strips(layout_info: layout_details, ax: Axes) Strips [source]¶
Create strips for the facet
- Parameters
- layout_infodict-like
Layout information. Row from the layout table
- ax
axes
Axes to label