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:
|
target
|
The target variable(s).
TYPE:
|
feature
|
The feature variable(s).
TYPE:
|
nrows
|
Number of rows in the subplot grid.
TYPE:
|
ncols
|
Number of columns in the subplot grid.
TYPE:
|
hue
|
The hue variable(s), by default ''.
TYPE:
|
shape
|
The shape variable(s), by default ''.
TYPE:
|
size
|
The size variable(s), by default ''.
TYPE:
|
dodge
|
Flag indicating whether dodging is enabled, by default False.
TYPE:
|
categorical_feature
|
Flag indicating whether feature is categorical, by default False.
TYPE:
|
target_on_y
|
Flag indicating whether target is on y-axis, by default True.
TYPE:
|
sharex
|
Flag indicating whether x-axis should be shared among subplots, by default False.
TYPE:
|
sharey
|
Flag indicating whether y-axis should be shared among subplots, by default False.
TYPE:
|
width_ratios
|
The width ratios for the subplot grid, by default None.
TYPE:
|
height_ratios
|
The height ratios for the subplot grid, by default None.
TYPE:
|
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:
|
colors
|
Tuple of unique colors used for hue categories as hex or str,
by default
TYPE:
|
markers
|
Tuple of markers used for shape marker categories as strings,
by default
TYPE:
|
n_size_bins
|
Number of bins for the size range, by default
TYPE:
|
**kwds
|
Additional keyword arguments for Chart initialization.
TYPE:
|
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:
|
| 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:
|
| 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:
|
kw_call
|
Additional keyword arguments for the plotter call method.
TYPE:
|
kw_where
|
Additional keyword arguments for the where method used to filter the data.
TYPE:
|
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:
|
**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 []. |
mean
|
Whether to plot the mean value of the plotted data on the axes, by default False.
TYPE:
|
median
|
Whether to plot the median value of the plotted data on the axes, by default False.
TYPE:
|
control_limits
|
Whether to plot control limits representing the process spread, by default False.
TYPE:
|
spec_limits
|
If provided, specifies the specification limits. Default is SpecLimits().
TYPE:
|
confidence
|
The confidence level between 0 and 1, by default None.
TYPE:
|
strategy
|
Which strategy should be used to determine the control
limits (process spread):
- Default is 'norm'.
TYPE:
|
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:
|
**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:
|
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:
|
sub_title
|
The subtitle for the entire figure, by default ''.
TYPE:
|
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:
|
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:
|
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:
|
axes_titles
|
Title for each Axes, by default ()
TYPE:
|
rows
|
The row labels of the figure, by default ().
TYPE:
|
cols
|
The column labels of the figure, by default ().
TYPE:
|
row_title
|
The title of the rows, by default ''.
TYPE:
|
col_title
|
The title of the columns, by default ''.
TYPE:
|
| 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.