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
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
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
str
in
['h', 'v']
Direction in which to layout the panels.
h
for horizontal andv
for vertical.
- scales
- params: dict[str, Any]¶
A dict of parameters created depending on the data (Intended for extensions)
- setup_data(data: list[DataFrame]) list[DataFrame] [source]¶
Allow the facet to manipulate the data
- Parameters:
- data
list
of
dataframes
Data for each of the layers
- data
- Returns:
- data
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[DataFrame])[source]¶
Create facet parameters
- Parameters:
- data
list
of
dataframes
Plot data and data for the layers
- data
- compute_layout(data: list[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.
- 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