MatplotLibAPI 3.2.14__py3-none-any.whl → 3.2.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ """Shared utilities for matplotlib-based plotting helpers."""
2
+
3
+ from typing import Any, Callable, Dict, Optional, Tuple, cast
4
+
5
+ import matplotlib.pyplot as plt
6
+ from numpy import ndarray
7
+ from matplotlib.axes import Axes
8
+ from matplotlib.figure import Figure
9
+ from typing_extensions import Protocol
10
+
11
+
12
+ class _AplotFunc(Protocol):
13
+ def __call__(self, *, pd_df: Any, ax: Axes, **kwargs: Any) -> Axes: ...
14
+
15
+
16
+ def _get_axis(ax: Optional[Axes] = None) -> Axes:
17
+ """Return a Matplotlib axes, defaulting to the current one."""
18
+ return ax if ax is not None else plt.gca()
19
+
20
+
21
+ def _wrap_aplot(
22
+ plot_func: _AplotFunc,
23
+ pd_df: Any,
24
+ figsize: Tuple[float, float],
25
+ ax_args: Optional[Dict[str, Any]] = None,
26
+ **kwargs: Any,
27
+ ) -> Figure:
28
+ """Create a new figure and delegate plotting to an axis-level function."""
29
+ ax_args = ax_args or {}
30
+ fig, axes_obj = plt.subplots(figsize=figsize, **ax_args)
31
+ ax: Axes
32
+ if isinstance(axes_obj, Axes):
33
+ ax = axes_obj
34
+ else:
35
+ ax = cast(Axes, axes_obj.flat[0] if isinstance(axes_obj, ndarray) else axes_obj)
36
+ plot_func(pd_df=pd_df, ax=ax, **kwargs)
37
+ fig_obj: Figure = cast(Figure, fig)
38
+ return fig_obj