Standard error mean
daspi.plotlib.plotter.StandardErrorMean(source, target, feature='', show_center=True, bars_same_color=False, skip_na=None, target_on_y=True, color=None, marker=None, ax=None, visible_spines=None, hide_axis=None, **kwds)
¶
Bases: Errorbar
Class for creating plotters with error bars representing the standard error of the mean.
| PARAMETER | DESCRIPTION |
|---|---|
source
|
Pandas long format DataFrame containing the data source for the plot.
TYPE:
|
target
|
Column name of the target variable for the plot.
TYPE:
|
feature
|
Column name of the feature variable for the plot, by default ''.
TYPE:
|
show_center
|
Flag indicating whether to show the center points, by default True.
TYPE:
|
bars_same_color
|
Flag indicating whether to use same color for error bars as markers for center. If False, the error bars are black,
TYPE:
|
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 by default False
TYPE:
|
target_on_y
|
Flag indicating whether the target variable is plotted on the y-axis, by default True.
TYPE:
|
color
|
Color to be used to draw the artists. If None, the first color is taken from the color cycle, by default None.
TYPE:
|
marker
|
The marker style for the center points. Available markers see: https://matplotlib.org/stable/api/markers_api.html, by default None
TYPE:
|
ax
|
The axes object for the plot. If None, the current axes is
fetched using
TYPE:
|
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:
|
hide_axis
|
Specifies which axes should be hidden. If None, both axes are displayed. Defaults to None.
TYPE:
|
**kwds
|
Additional keyword arguments that have no effect and are only used to catch further arguments that have no use here (occurs when this class is used within chart objects).
DEFAULT:
|
Examples:
Apply to an existing Axes object:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from daspi import StandardErrorMean
fig, ax = plt.subplots()
df = pd.DataFrame(dict(
x = ['first'] * 50 + ['second'] * 50 + ['third'] * 50,
y = (
list(np.random.normal(loc=3, scale=1, size=50))
+ list(np.random.normal(loc=4, scale=1, size=50))
+ list(np.random.normal(loc=2, scale=1, size=50)))))
sem = StandardErrorMean(
source=df, target='y', feature='x',
show_center=True, bars_same_color=True, ax=ax)
sem(kw_center=dict(s=30, marker='_'))
sem.label_feature_ticks()
Apply using the plot method of a DaSPi Chart object:
import numpy as np
import daspi as dsp
import pandas as pd
df = pd.DataFrame(dict(
x = ['first'] * 50 + ['second'] * 50 + ['third'] * 50,
y = (
list(np.random.normal(loc=3, scale=1, size=50))
+ list(np.random.normal(loc=4, scale=1, size=50))
+ list(np.random.normal(loc=2, scale=1, size=50)))))
chart = dsp.SingleChart(
source=df,
target='y',
feature='x',
categorical_feature=True, # neded to label the feature tick labels
).plot(
dsp.StandardErrorMean,
show_center=True,
bars_same_color=True,
kw_call=dict(kw_center=dict(s=30, marker='_'))
).label() # neded to label the feature tick labels
transform(feature_data, target_data)
¶
Perform the transformation on the target data using the
Estimator class and return the transformed data.
| PARAMETER | DESCRIPTION |
|---|---|
feature_data
|
Base location (offset) of feature axis coming from
TYPE:
|
target_data
|
Feature grouped target data used for transformation, coming
from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
data
|
The transformed data source for the plot.
TYPE:
|