stub
Create margin annotations for data outside axes viewport.
Functions
|
Rescale the axes of a Matplotlib axes with plotted points to exclude outliers. |
|
Draw edge markers for points lying outside the plot's bounds. |
|
Draw an edge marker for a single clipped point. |
Classes
Functor to set outlier bounds a fixed ratio above/below interquartile range. |
- class CalcBoundsIQR[source]
Functor to set outlier bounds a fixed ratio above/below interquartile range.
Bounds are calculated as (q1 - iqr_multiplier * iqr, q3 + iqr_multiplier * iqr), where q1 and q3 are the first and third quartiles, respectively, and iqr is the interquartile range (q3 - q1).
- __init__(iqr_multiplier: float = 1.5) None [source]
Initialize functor.
- Parameters:
iqr_multiplier (float, default 1.5) – The multiplier applied to the IQR to determine the bounds.
- __call__(data: Sequence[float]) Tuple[float, float] [source]
Calculate the lower and upper bounds of the input data using the IQR method.
- Parameters:
data (np.ndarray) – The input data for which the bounds are calculated.
- Returns:
bounds – Lower and upper calculated bounds.
- Return type:
Tuple[float, float]
- rescale_clip_outliers(ax: Axes | None = None, calc_outlier_bounds: Callable | Tuple[Callable, Callable] | None = None, *, pad: float = 0.1) None [source]
Rescale the axes of a Matplotlib axes with plotted points to exclude outliers.
This function inspects plotted points already on the axes object.
- Parameters:
ax (mpl_Axes, optional) –
The Matplotlib Axes object to rescale.
If None, plt.gca() will be used.
calc_outlier_bounds (Union[Callable, Tuple[Callable, Callable]], optional) –
A function or a tuple of two functions to calculate the outlier bounds for the x and y data points.
Each function should accept an array of data points and return a tuple of (lower, upper) bounds. If None, defaults to interquartile range-based calculation (CalcBoundsIQR with multiplier 1.5).
pad (float, default 0.1) – How far should axes limits be padded beyond the non-outlier data range?
- Return type:
None
Notes
In cases where there are no outliers or all points are outliers, axes limits will not be adjusted In cases where non-outliers take on only a single value, padding will be applied relative to that value or, if zero, one.
- stub_all_clipped_values(ax: Axes, *, marker_kws: Dict = frozendict.frozendict({}), offset: float = 0.1) None [source]
Draw edge markers for points lying outside the plot’s bounds.
The original point and associated error bar (if any) is moved into the margin with a note indicating the original location. If the point is out of xlim and out of ylim, the point will be retrieved with two edge markers (horizontal and vertical).
- Parameters:
ax (matplotlib.axes.Axes) – The axes object to draw markers on.
marker_kws (dict, optional) – Keyword arguments forwarded to matplotlib plot for edge markers.
offset (float, default 0.1) – How far outside axis viewport to draw edge markers, proportional to axis viewport height or width.
Notes
Full error bar support for values below lower {x,y}lim remains be implemented. Current implementation assumes each error bar is associated with a scatter point.
- stub_edge_mark(ax: Axes, x: float, y: float, *, marker_kws: Dict = frozendict.frozendict({}), offset: float = 0.1) Tuple[float, float] [source]
Draw an edge marker for a single clipped point.
- Parameters:
ax (matplotlib.axes.Axes) – The axes object to draw markers on.
x (float) – The x and y coordinates of the point.
y (float) – The x and y coordinates of the point.
marker_kws (dict, optional) – Keyword arguments forwarded to matplotlib plot for edge markers.
offset (float, default 0.1) – How far outside axis viewport to draw edge markers, proportional to axis viewport height or width.
- Returns:
edge_x, edge_y – The x and y coordinates of the placed edge marker.
- Return type:
float
See also
outset.stub.stub_all_clipped_values
Automates out of bounds scatterpoint detection and stub creation.