Skip to content

Transform plotter

daspi.plotlib.plotter.TransformPlotter(source, target, feature='', f_base=DEFAULT.FEATURE_BASE, skip_na=None, target_on_y=True, color=None, ax=None, visible_spines=None, hide_axis=None, **kwds)

Bases: Plotter

Abstract base class for creating plotters.

PARAMETER DESCRIPTION
source

Pandas long format DataFrame containing the data source for the plot.

TYPE: pandas DataFrame

target

Column name of the target variable for the plot.

TYPE: str

feature

Column name of the feature variable for the plot, by default ''

TYPE: str DEFAULT: ''

f_base

Value that serves as the base location (offset) of the feature values. Only taken into account if feature is not given, by default DEFAULT.FEATURE_BASE.

TYPE: int | float DEFAULT: FEATURE_BASE

skip_na

Flag indicating whether to skip missing values in the feature grouped data, by default None - None, no missing values are skipped - all', grouped data is skipped if all values are missing - any', grouped data is skipped if any value is missing

TYPE: Literal['none', 'all', 'any'] DEFAULT: None

target_on_y

Flag indicating whether the target variable is plotted on the y-axis, by default True

TYPE: bool DEFAULT: True

color

Color to be used to draw the artists. If None, the first color is taken from the color cycle, by default None.

TYPE: str | None DEFAULT: None

ax

The axes object for the plot. If None, the current axes is fetched using plt.gca(). If no axes are available, a new one is created. Defaults to None.

TYPE: Axes | None DEFAULT: None

visible_spines

Specifies which spines are visible, the others are hidden. If 'none', no spines are visible. If None, the spines are drawn according to the stylesheet. Defaults to None.

TYPE: Literal['target', 'feature', 'none'] | None DEFAULT: None

hide_axis

Specifies which axes should be hidden. If None, both axes are displayed. Defaults to None.

TYPE: Literal['target', 'feature', 'both'] | None DEFAULT: None

**kwds

Those arguments have no effect. Only serves to catch further arguments that have no use here (occurs when this class is used within chart objects).

DEFAULT: {}

skip_na = skip_na instance-attribute

Flag indicating whether to skip missing values in the feature grouped data. - None: no missing values are skipped - 'all': grouped data is skipped if all values are missing - 'any': grouped data is skipped if any value is missing

feature_grouped(source)

Group the data by the feature variable and yield the transformed data for each group.

PARAMETER DESCRIPTION
source

Pandas long format DataFrame containing the data source for the plot.

TYPE: pandas DataFrame

YIELDS DESCRIPTION
feature_data

Base location (offset) of feature axis.

TYPE:: int | float

target_data

feature grouped target data used for transformation.

TYPE:: pandas Series

transform(feature_data, target_data) abstractmethod

Perform the transformation on the target data and return the transformed data.

This method should be overridden by subclasses to provide the specific plotting functionality.

PARAMETER DESCRIPTION
feature_data

Base location (offset) of feature axis coming from `feature_grouped' generator.

TYPE: int | float

target_data

feature grouped target data used for transformation, coming from `feature_grouped' generator.

TYPE: pandas Series

RETURNS DESCRIPTION
data

The transformed data source for the plot.

TYPE: pandas DataFrame