File size: 14,699 Bytes
7d8711c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
from collections.abc import Callable, Hashable, Iterable, Sequence
import os
from typing import Any, IO, Literal, TypeVar, overload
import numpy as np
from numpy.typing import ArrayLike
from matplotlib.artist import Artist
from matplotlib.axes import Axes
from matplotlib.backend_bases import (
FigureCanvasBase,
MouseButton,
MouseEvent,
RendererBase,
)
from matplotlib.colors import Colormap, Normalize
from matplotlib.colorbar import Colorbar
from matplotlib.colorizer import ColorizingArtist, Colorizer
from matplotlib.cm import ScalarMappable
from matplotlib.gridspec import GridSpec, SubplotSpec, SubplotParams as SubplotParams
from matplotlib.image import _ImageBase, FigureImage
from matplotlib.layout_engine import LayoutEngine
from matplotlib.legend import Legend
from matplotlib.lines import Line2D
from matplotlib.patches import Rectangle, Patch
from matplotlib.text import Text
from matplotlib.transforms import Affine2D, Bbox, BboxBase, Transform
from .typing import ColorType, HashableList
_T = TypeVar("_T")
class FigureBase(Artist):
artists: list[Artist]
lines: list[Line2D]
patches: list[Patch]
texts: list[Text]
images: list[_ImageBase]
legends: list[Legend]
subfigs: list[SubFigure]
stale: bool
suppressComposite: bool | None
def __init__(self, **kwargs) -> None: ...
def autofmt_xdate(
self,
bottom: float = ...,
rotation: int = ...,
ha: Literal["left", "center", "right"] = ...,
which: Literal["major", "minor", "both"] = ...,
) -> None: ...
def get_children(self) -> list[Artist]: ...
def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict[Any, Any]]: ...
def suptitle(self, t: str, **kwargs) -> Text: ...
def get_suptitle(self) -> str: ...
def supxlabel(self, t: str, **kwargs) -> Text: ...
def get_supxlabel(self) -> str: ...
def supylabel(self, t: str, **kwargs) -> Text: ...
def get_supylabel(self) -> str: ...
def get_edgecolor(self) -> ColorType: ...
def get_facecolor(self) -> ColorType: ...
def get_frameon(self) -> bool: ...
def set_linewidth(self, linewidth: float) -> None: ...
def get_linewidth(self) -> float: ...
def set_edgecolor(self, color: ColorType) -> None: ...
def set_facecolor(self, color: ColorType) -> None: ...
@overload
def get_figure(self, root: Literal[True]) -> Figure: ...
@overload
def get_figure(self, root: Literal[False]) -> Figure | SubFigure: ...
@overload
def get_figure(self, root: bool = ...) -> Figure | SubFigure: ...
def set_frameon(self, b: bool) -> None: ...
@property
def frameon(self) -> bool: ...
@frameon.setter
def frameon(self, b: bool) -> None: ...
def add_artist(self, artist: Artist, clip: bool = ...) -> Artist: ...
@overload
def add_axes(self, ax: Axes) -> Axes: ...
@overload
def add_axes(
self,
rect: tuple[float, float, float, float],
projection: None | str = ...,
polar: bool = ...,
**kwargs
) -> Axes: ...
# TODO: docstring indicates SubplotSpec a valid arg, but none of the listed signatures appear to be that
@overload
def add_subplot(
self, nrows: int, ncols: int, index: int | tuple[int, int], **kwargs
) -> Axes: ...
@overload
def add_subplot(self, pos: int, **kwargs) -> Axes: ...
@overload
def add_subplot(self, ax: Axes, **kwargs) -> Axes: ...
@overload
def add_subplot(self, ax: SubplotSpec, **kwargs) -> Axes: ...
@overload
def add_subplot(self, **kwargs) -> Axes: ...
@overload
def subplots(
self,
nrows: Literal[1] = ...,
ncols: Literal[1] = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[True] = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> Axes: ...
@overload
def subplots(
self,
nrows: int = ...,
ncols: int = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[False],
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> np.ndarray: ... # TODO numpy/numpy#24738
@overload
def subplots(
self,
nrows: int = ...,
ncols: int = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: bool = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> Any: ...
def delaxes(self, ax: Axes) -> None: ...
def clear(self, keep_observers: bool = ...) -> None: ...
def clf(self, keep_observers: bool = ...) -> None: ...
@overload
def legend(self) -> Legend: ...
@overload
def legend(self, handles: Iterable[Artist], labels: Iterable[str], **kwargs) -> Legend: ...
@overload
def legend(self, *, handles: Iterable[Artist], **kwargs) -> Legend: ...
@overload
def legend(self, labels: Iterable[str], **kwargs) -> Legend: ...
@overload
def legend(self, **kwargs) -> Legend: ...
def text(
self,
x: float,
y: float,
s: str,
fontdict: dict[str, Any] | None = ...,
**kwargs
) -> Text: ...
def colorbar(
self,
mappable: ScalarMappable | ColorizingArtist,
cax: Axes | None = ...,
ax: Axes | Iterable[Axes] | None = ...,
use_gridspec: bool = ...,
**kwargs
) -> Colorbar: ...
def subplots_adjust(
self,
left: float | None = ...,
bottom: float | None = ...,
right: float | None = ...,
top: float | None = ...,
wspace: float | None = ...,
hspace: float | None = ...,
) -> None: ...
def align_xlabels(self, axs: Iterable[Axes] | None = ...) -> None: ...
def align_ylabels(self, axs: Iterable[Axes] | None = ...) -> None: ...
def align_titles(self, axs: Iterable[Axes] | None = ...) -> None: ...
def align_labels(self, axs: Iterable[Axes] | None = ...) -> None: ...
def add_gridspec(self, nrows: int = ..., ncols: int = ..., **kwargs) -> GridSpec: ...
@overload
def subfigures(
self,
nrows: int = ...,
ncols: int = ...,
squeeze: Literal[False] = ...,
wspace: float | None = ...,
hspace: float | None = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
**kwargs
) -> np.ndarray: ...
@overload
def subfigures(
self,
nrows: int = ...,
ncols: int = ...,
squeeze: Literal[True] = ...,
wspace: float | None = ...,
hspace: float | None = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
**kwargs
) -> np.ndarray | SubFigure: ...
def add_subfigure(self, subplotspec: SubplotSpec, **kwargs) -> SubFigure: ...
def sca(self, a: Axes) -> Axes: ...
def gca(self) -> Axes: ...
def _gci(self) -> ColorizingArtist | None: ...
def _process_projection_requirements(
self, *, axes_class=None, polar=False, projection=None, **kwargs
) -> tuple[type[Axes], dict[str, Any]]: ...
def get_default_bbox_extra_artists(self) -> list[Artist]: ...
def get_tightbbox(
self,
renderer: RendererBase | None = ...,
*,
bbox_extra_artists: Iterable[Artist] | None = ...,
) -> Bbox: ...
@overload
def subplot_mosaic(
self,
mosaic: str,
*,
sharex: bool = ...,
sharey: bool = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
empty_sentinel: str = ...,
subplot_kw: dict[str, Any] | None = ...,
per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> dict[str, Axes]: ...
@overload
def subplot_mosaic(
self,
mosaic: list[HashableList[_T]],
*,
sharex: bool = ...,
sharey: bool = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
empty_sentinel: _T = ...,
subplot_kw: dict[str, Any] | None = ...,
per_subplot_kw: dict[_T | tuple[_T, ...], dict[str, Any]] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> dict[_T, Axes]: ...
@overload
def subplot_mosaic(
self,
mosaic: list[HashableList[Hashable]],
*,
sharex: bool = ...,
sharey: bool = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
empty_sentinel: Any = ...,
subplot_kw: dict[str, Any] | None = ...,
per_subplot_kw: dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
) -> dict[Hashable, Axes]: ...
class SubFigure(FigureBase):
@property
def figure(self) -> Figure: ...
subplotpars: SubplotParams
dpi_scale_trans: Affine2D
transFigure: Transform
bbox_relative: Bbox
figbbox: BboxBase
bbox: BboxBase
transSubfigure: Transform
patch: Rectangle
def __init__(
self,
parent: Figure | SubFigure,
subplotspec: SubplotSpec,
*,
facecolor: ColorType | None = ...,
edgecolor: ColorType | None = ...,
linewidth: float = ...,
frameon: bool | None = ...,
**kwargs
) -> None: ...
@property
def canvas(self) -> FigureCanvasBase: ...
@property
def dpi(self) -> float: ...
@dpi.setter
def dpi(self, value: float) -> None: ...
def get_dpi(self) -> float: ...
def set_dpi(self, val) -> None: ...
def get_constrained_layout(self) -> bool: ...
def get_constrained_layout_pads(
self, relative: bool = ...
) -> tuple[float, float, float, float]: ...
def get_layout_engine(self) -> LayoutEngine: ...
@property # type: ignore[misc]
def axes(self) -> list[Axes]: ... # type: ignore[override]
def get_axes(self) -> list[Axes]: ...
class Figure(FigureBase):
@property
def figure(self) -> Figure: ...
bbox_inches: Bbox
dpi_scale_trans: Affine2D
bbox: BboxBase
figbbox: BboxBase
transFigure: Transform
transSubfigure: Transform
patch: Rectangle
subplotpars: SubplotParams
def __init__(
self,
figsize: tuple[float, float] | None = ...,
dpi: float | None = ...,
*,
facecolor: ColorType | None = ...,
edgecolor: ColorType | None = ...,
linewidth: float = ...,
frameon: bool | None = ...,
subplotpars: SubplotParams | None = ...,
tight_layout: bool | dict[str, Any] | None = ...,
constrained_layout: bool | dict[str, Any] | None = ...,
layout: Literal["constrained", "compressed", "tight"]
| LayoutEngine
| None = ...,
**kwargs
) -> None: ...
def pick(self, mouseevent: MouseEvent) -> None: ...
def set_layout_engine(
self,
layout: Literal["constrained", "compressed", "tight", "none"]
| LayoutEngine
| None = ...,
**kwargs
) -> None: ...
def get_layout_engine(self) -> LayoutEngine | None: ...
def _repr_html_(self) -> str | None: ...
def show(self, warn: bool = ...) -> None: ...
@property
def number(self) -> int | str: ...
@number.setter
def number(self, num: int | str) -> None: ...
@property # type: ignore[misc]
def axes(self) -> list[Axes]: ... # type: ignore[override]
def get_axes(self) -> list[Axes]: ...
@property
def dpi(self) -> float: ...
@dpi.setter
def dpi(self, dpi: float) -> None: ...
def get_tight_layout(self) -> bool: ...
def get_constrained_layout_pads(
self, relative: bool = ...
) -> tuple[float, float, float, float]: ...
def get_constrained_layout(self) -> bool: ...
canvas: FigureCanvasBase
def set_canvas(self, canvas: FigureCanvasBase) -> None: ...
def figimage(
self,
X: ArrayLike,
xo: int = ...,
yo: int = ...,
alpha: float | None = ...,
norm: str | Normalize | None = ...,
cmap: str | Colormap | None = ...,
vmin: float | None = ...,
vmax: float | None = ...,
origin: Literal["upper", "lower"] | None = ...,
resize: bool = ...,
*,
colorizer: Colorizer | None = ...,
**kwargs
) -> FigureImage: ...
def set_size_inches(
self, w: float | tuple[float, float], h: float | None = ..., forward: bool = ...
) -> None: ...
def get_size_inches(self) -> np.ndarray: ...
def get_figwidth(self) -> float: ...
def get_figheight(self) -> float: ...
def get_dpi(self) -> float: ...
def set_dpi(self, val: float) -> None: ...
def set_figwidth(self, val: float, forward: bool = ...) -> None: ...
def set_figheight(self, val: float, forward: bool = ...) -> None: ...
def clear(self, keep_observers: bool = ...) -> None: ...
def draw_without_rendering(self) -> None: ...
def draw_artist(self, a: Artist) -> None: ...
def add_axobserver(self, func: Callable[[Figure], Any]) -> None: ...
def savefig(
self,
fname: str | os.PathLike | IO,
*,
transparent: bool | None = ...,
**kwargs
) -> None: ...
def ginput(
self,
n: int = ...,
timeout: float = ...,
show_clicks: bool = ...,
mouse_add: MouseButton = ...,
mouse_pop: MouseButton = ...,
mouse_stop: MouseButton = ...,
) -> list[tuple[int, int]]: ...
def waitforbuttonpress(self, timeout: float = ...) -> None | bool: ...
def tight_layout(
self,
*,
pad: float = ...,
h_pad: float | None = ...,
w_pad: float | None = ...,
rect: tuple[float, float, float, float] | None = ...
) -> None: ...
def figaspect(arg: float | ArrayLike) -> tuple[float, float]: ...
|