Skip to content

Joint chart

daspi.plotlib.chart.JointChart(source, target, feature, *, nrows=None, ncols=None, mosaic=None, hue='', shape='', size='', dodge=False, categorical_feature=False, target_on_y=True, sharex='none', sharey='none', width_ratios=None, height_ratios=None, stretch_figsize=False, colors=None, markers=None, n_size_bins=CATEGORY.N_SIZE_BINS, **kwds)

Bases: Chart

Represents a joint chart visualization combining multiple SingleCharts.

Inherits from Chart.

PARAMETER DESCRIPTION
source

The source data.

TYPE: DataFrame

target

The target variable(s).

TYPE: str or Tuple[str]

feature

The feature variable(s).

TYPE: str or Tuple[str]

nrows

Number of rows in the subplot grid.

TYPE: int DEFAULT: None

ncols

Number of columns in the subplot grid.

TYPE: int DEFAULT: None

hue

The hue variable(s), by default ''.

TYPE: str or Tuple[str] DEFAULT: ''

shape

The shape variable(s), by default ''.

TYPE: str or Tuple[str] DEFAULT: ''

size

The size variable(s), by default ''.

TYPE: str or Tuple[str] DEFAULT: ''

dodge

Flag indicating whether dodging is enabled, by default False.

TYPE: bool or Tuple[bool] DEFAULT: False

categorical_feature

Flag indicating whether feature is categorical, by default False.

TYPE: bool or Tuple[str] DEFAULT: False

target_on_y

Flag indicating whether target is on y-axis, by default True.

TYPE: bool or List[bool] DEFAULT: True

sharex

Flag indicating whether x-axis should be shared among subplots, by default False.

TYPE: ShareAxisProperty DEFAULT: 'none'

sharey

Flag indicating whether y-axis should be shared among subplots, by default False.

TYPE: ShareAxisProperty DEFAULT: 'none'

width_ratios

The width ratios for the subplot grid, by default None.

TYPE: List[float] DEFAULT: None

height_ratios

The height ratios for the subplot grid, by default None.

TYPE: List[float] DEFAULT: None

stretch_figsize

If True, the height and width of the figure are stretched based on the number rows and columns in the axes grid. If a float is provided, the figure size is stretched by the given factor. If a tuple of two floats is provided, the figure size is stretched by the given factors for the x and y axis, respectively. by default False.

TYPE: bool | float | Tuple[float, float] DEFAULT: False

colors

Tuple of unique colors used for hue categories as hex or str, by default CATEGORY.PALETTE.

TYPE: Tuple[str, ...] | None DEFAULT: None

markers

Tuple of markers used for shape marker categories as strings, by default CATEGORY.MARKERS.

TYPE: Tuple[str, ...] DEFAULT: None

n_size_bins

Number of bins for the size range, by default CATEGORY.N_SIZE_BINS.

TYPE: int DEFAULT: N_SIZE_BINS

**kwds

Additional keyword arguments for Chart initialization.

TYPE: dict DEFAULT: {}

charts = [] instance-attribute

List of SingleChart instances created for each Axis throughout the chart.

sources = self.normalize_to_tuple(source) instance-attribute

The source data associated with each subplot

targets = self.normalize_to_tuple(target) instance-attribute

Column names for the target variable to be visualized for each axes.

features = self.normalize_to_tuple(feature) instance-attribute

Column names for the feature variable to be visualized for each axes.

hues = self.normalize_to_tuple(hue) instance-attribute

The hue variable (column) for color differentiation for each axes.

shapes = self.normalize_to_tuple(shape) instance-attribute

The shape variables (column) for marker differentiation for each axes.

sizes = self.normalize_to_tuple(size) instance-attribute

The size variable (column) for marker size differentiation for each axes.

dodges = self.normalize_to_tuple(dodge) instance-attribute

Flag indicating whether dodging is enabled for each axes.

categorical_features = tuple((dodge or categorical) for dodge, categorical in (zip(self.dodges, self.normalize_to_tuple(categorical_feature)))) instance-attribute

Flags indicating if feature is categorical for each axes.

target_on_ys = self.normalize_to_tuple(target_on_y) instance-attribute

Flags indicating whether target is on y-axis for each axes.

target_on_y = self.target_on_ys[0] instance-attribute

Flag indicating whether target is on y-axis for current chart. This flag is set during iterating over charts.

same_target_on_y property

True if all target_on_y have the same boolean value.

legend_data property

Get dictionary of handles and labels (read-only). - keys: titles as str - values: handles and labels as tuple of tuples

plots property

Get plotter objects used in plot method

axes_share_feature property

Get the sharing of properties along the feature-axis (read-only).

axes_share_target property

Get the sharing of properties along the target-axis (read-only).

single_label_allowed(is_target)

Determines whether a single label is allowed for the specified axis.

This method checks whether a single axis label is allowed for either target or feature dimensions based on certain conditions. The same_target_on_y attribute is allways considered. It is also checked whether the number of unique values in the respective dimension (features or targets) is 1 or whether the sharing of the axis is set to True or 'all'.

PARAMETER DESCRIPTION
is_target

If True, checks for target labels; otherwise, checks for feature labels.

TYPE: bool

RETURNS DESCRIPTION
bool

True if a single label is allowed, False otherwise.

itercharts()

Iter over charts simultaneosly iters over axes of axes. That ensures that the current Axes to which the current chart belongs is set. The

normalize_to_tuple(attribute)

Normalize the input attribute to ensure it is a tuple with a length equal to the number of subplots (n_axes). If a single value is provided, it is replicated to create a tuple with the same length as n_axes.

PARAMETER DESCRIPTION
attribute

A single value or a list/tuple of values.

TYPE: (str, float, int, bool, list, tuple or None)

RETURNS DESCRIPTION
tuple

A tuple containing the normalized values.

RAISES DESCRIPTION
ValueError

If the input type is not supported

AssertionError

If the length of the attribute does not match n_axes after normalization.

Examples:

Suppose n_axes is 3: - If attribute is 5, it will return (5, 5, 5). - If attribute is [], it will return ([], [], []). - If attribute is (1, 2, 3), it will return (1, 2, 3). - If attribute is (1, 2), it will raise a ValueError.

axis_labels(feature_label, target_label)

Get the x and y axis labels based on the provided feature_label and target_label.

plot(plotter, *, kw_call={}, kw_where={}, on_last_axes=False, **kwds)

Plot the data using the specified plotter.

PARAMETER DESCRIPTION
plotter

The plotter object.

TYPE: Type[Plotter]

kw_call

Additional keyword arguments for the plotter call method.

TYPE: Dict[str, Any] DEFAULT: {}

kw_where

Additional keyword arguments for the where method used to filter the data.

TYPE: Dict[str, Any] DEFAULT: {}

on_last_axes

If True, plot on the last axes in the grid. If False, plot on the next axes in the grid, by default False.

TYPE: bool DEFAULT: False

**kwds

Additional keyword arguments for the plotter object. Here you can set the plotter specific initialization parameters. You can also override the standard parameters color, marker, target_on_y, size (marker size) and width (for categorical feature plots).

DEFAULT: {}

RETURNS DESCRIPTION
JointChart

The updated JointChart instance after plotting.

Notes

Call the plot method for each individual Axes in the flattened grid. You can specify the desired plotter for each chart individually. The order of plotting corresponds to the flattened arrangement of the subplots. Feel free to use this method to create customized visualizations for each subplot.

stripes(stripes=[], *, mean=False, median=False, control_limits=False, spec_limits=SpecLimits(), confidence=None, strategy='norm', agreement=6, **kwds)

Plot location and spread width lines, specification limits and/or confidence interval areas as stripes on each Axes. The location and spread (and their confidence bands) represent the data per axes.

PARAMETER DESCRIPTION
stripes

Additional non-predefined stripes to be added to the chart. Default is [].

TYPE: List[Stripe] | Tuple[List[Stripe]] DEFAULT: []

mean

Whether to plot the mean value of the plotted data on the axes, by default False.

TYPE: bool or Tuple[bool, ...] DEFAULT: False

median

Whether to plot the median value of the plotted data on the axes, by default False.

TYPE: bool or Tuple[bool, ...] DEFAULT: False

control_limits

Whether to plot control limits representing the process spread, by default False.

TYPE: bool or Tuple[bool, ...] DEFAULT: False

spec_limits

If provided, specifies the specification limits. Default is SpecLimits().

TYPE: SpecLimits | Tuple[SpecLimits, ...] DEFAULT: SpecLimits()

confidence

The confidence level between 0 and 1, by default None.

TYPE: float | None | Tuple[float | None, ...] DEFAULT: None

strategy

Which strategy should be used to determine the control limits (process spread): - eval: The strategy is determined according to the given evaluate function. If none is given, the internal evaluate method is used. - fit: First, the distribution that best represents the process data is searched for and then the agreed process spread is calculated - norm: it is assumed that the data is subject to normal distribution. The variation tolerance is then calculated as agreement * standard deviation - data: The quantiles for the process variation tolerance are read directly from the data.

Default is 'norm'.

TYPE: (eval, fit, norm, data) DEFAULT: 'eval'

agreement

Specify the tolerated process variation for which the control limits are to be calculated. - If int, the spread is determined using the normal distribution agreementsigma, e.g. agreement = 6 -> 6sigma ~ covers 99.75 % of the data. The upper and lower permissible quantiles are then calculated from this. - If float, the value must be between 0 and 1.This value is then interpreted as the acceptable proportion for the spread, e.g. 0.9973 (which corresponds to ~ 6 sigma)

Default is 6 because SixSigma ;-)

TYPE: int | float | Tuple[int | float, ...] DEFAULT: 6

**kwds

Additional keyword arguments for configuring StripesFacets.

DEFAULT: {}

RETURNS DESCRIPTION
JointChart

The instance of the JointChart with the specified stripes plotted on the axes.

TYPE: Self

Notes

The given arguments are applied to all axes! If stripes should only be drawn on selected axes, select the desired subchart via charts attributes. Then use its stripes method.

This method plots stripes on the chart axes to represent statistical measures such as mean, median, control limits, and specification limits. The method provides options to customize the appearance and behavior of the stripes using various parameters and keyword arguments.

label(*, fig_title='', sub_title='', feature_label='', target_label='', info=False, axes_titles=(), rows=(), cols=(), row_title='', col_title='')

Add labels and titles to the chart.

This method sets various labels and titles for the chart, including figure title, subplot title, axis labels, row and column titles, and additional information.

PARAMETER DESCRIPTION
fig_title

The main title for the entire figure, by default ''.

TYPE: str DEFAULT: ''

sub_title

The subtitle for the entire figure, by default ''.

TYPE: str DEFAULT: ''

feature_label

The label for the feature variable (x-axis), by default ''. If set to True, the feature variable name will be used. If set to False or None, no label will be added.

TYPE: str | bool | None DEFAULT: ''

target_label

The label for the target variable (y-axis), by default ''. If set to True, the target variable name will be used. If set to False or None, no label will be added.

TYPE: str | bool | None DEFAULT: ''

info

Additional information to display on the chart. If True, the date and user information will be automatically added at the lower left corner of the figure. If a string is provided, it will be shown next to the date and user, separated by a comma. By default, no additional information is displayed.

TYPE: bool | str DEFAULT: False

axes_titles

Title for each Axes, by default ()

TYPE: Tuple[str, ...] DEFAULT: ()

rows

The row labels of the figure, by default ().

TYPE: Tuple[str, ...] DEFAULT: ()

cols

The column labels of the figure, by default ().

TYPE: Tuple[str, ...] DEFAULT: ()

row_title

The title of the rows, by default ''.

TYPE: str DEFAULT: ''

col_title

The title of the columns, by default ''.

TYPE: str DEFAULT: ''

RETURNS DESCRIPTION
JointChart

The instance of the JointChart with updated labels and titles.

Notes

This method allows customization of chart labels and titles to enhance readability and provide context for the visualized data.