_base.pyi 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. import matplotlib.artist as martist
  2. import datetime
  3. from collections.abc import Callable, Iterable, Iterator, Sequence
  4. from matplotlib import cbook
  5. from matplotlib.artist import Artist
  6. from matplotlib.axes import Axes
  7. from matplotlib.axis import XAxis, YAxis, Tick
  8. from matplotlib.backend_bases import RendererBase, MouseButton, MouseEvent
  9. from matplotlib.cbook import CallbackRegistry
  10. from matplotlib.container import Container
  11. from matplotlib.collections import Collection
  12. from matplotlib.colorizer import ColorizingArtist
  13. from matplotlib.legend import Legend
  14. from matplotlib.lines import Line2D
  15. from matplotlib.gridspec import SubplotSpec, GridSpec
  16. from matplotlib.figure import Figure, SubFigure
  17. from matplotlib.image import AxesImage
  18. from matplotlib.patches import Patch
  19. from matplotlib.scale import ScaleBase
  20. from matplotlib.spines import Spines
  21. from matplotlib.table import Table
  22. from matplotlib.text import Text
  23. from matplotlib.transforms import Transform, Bbox
  24. from cycler import Cycler
  25. import numpy as np
  26. from numpy.typing import ArrayLike
  27. from typing import Any, Literal, TypeVar, overload
  28. from matplotlib.typing import ColorType
  29. _T = TypeVar("_T", bound=Artist)
  30. class _axis_method_wrapper:
  31. attr_name: str
  32. method_name: str
  33. __doc__: str
  34. def __init__(
  35. self, attr_name: str, method_name: str, *, doc_sub: dict[str, str] | None = ...
  36. ) -> None: ...
  37. def __set_name__(self, owner: Any, name: str) -> None: ...
  38. class _AxesBase(martist.Artist):
  39. name: str
  40. patch: Patch
  41. spines: Spines
  42. fmt_xdata: Callable[[float], str] | None
  43. fmt_ydata: Callable[[float], str] | None
  44. xaxis: XAxis
  45. yaxis: YAxis
  46. bbox: Bbox
  47. dataLim: Bbox
  48. transAxes: Transform
  49. transScale: Transform
  50. transLimits: Transform
  51. transData: Transform
  52. ignore_existing_data_limits: bool
  53. axison: bool
  54. containers: list[Container]
  55. callbacks: CallbackRegistry
  56. child_axes: list[_AxesBase]
  57. legend_: Legend | None
  58. title: Text
  59. _projection_init: Any
  60. def __init__(
  61. self,
  62. fig: Figure,
  63. *args: tuple[float, float, float, float] | Bbox | int,
  64. facecolor: ColorType | None = ...,
  65. frameon: bool = ...,
  66. sharex: _AxesBase | None = ...,
  67. sharey: _AxesBase | None = ...,
  68. label: Any = ...,
  69. xscale: str | ScaleBase | None = ...,
  70. yscale: str | ScaleBase | None = ...,
  71. box_aspect: float | None = ...,
  72. forward_navigation_events: bool | Literal["auto"] = ...,
  73. **kwargs
  74. ) -> None: ...
  75. def get_subplotspec(self) -> SubplotSpec | None: ...
  76. def set_subplotspec(self, subplotspec: SubplotSpec) -> None: ...
  77. def get_gridspec(self) -> GridSpec | None: ...
  78. def set_figure(self, fig: Figure | SubFigure) -> None: ...
  79. @property
  80. def viewLim(self) -> Bbox: ...
  81. def get_xaxis_transform(
  82. self, which: Literal["grid", "tick1", "tick2"] = ...
  83. ) -> Transform: ...
  84. def get_xaxis_text1_transform(
  85. self, pad_points: float
  86. ) -> tuple[
  87. Transform,
  88. Literal["center", "top", "bottom", "baseline", "center_baseline"],
  89. Literal["center", "left", "right"],
  90. ]: ...
  91. def get_xaxis_text2_transform(
  92. self, pad_points
  93. ) -> tuple[
  94. Transform,
  95. Literal["center", "top", "bottom", "baseline", "center_baseline"],
  96. Literal["center", "left", "right"],
  97. ]: ...
  98. def get_yaxis_transform(
  99. self, which: Literal["grid", "tick1", "tick2"] = ...
  100. ) -> Transform: ...
  101. def get_yaxis_text1_transform(
  102. self, pad_points
  103. ) -> tuple[
  104. Transform,
  105. Literal["center", "top", "bottom", "baseline", "center_baseline"],
  106. Literal["center", "left", "right"],
  107. ]: ...
  108. def get_yaxis_text2_transform(
  109. self, pad_points
  110. ) -> tuple[
  111. Transform,
  112. Literal["center", "top", "bottom", "baseline", "center_baseline"],
  113. Literal["center", "left", "right"],
  114. ]: ...
  115. def get_position(self, original: bool = ...) -> Bbox: ...
  116. def set_position(
  117. self,
  118. pos: Bbox | tuple[float, float, float, float],
  119. which: Literal["both", "active", "original"] = ...,
  120. ) -> None: ...
  121. def reset_position(self) -> None: ...
  122. def set_axes_locator(
  123. self, locator: Callable[[_AxesBase, RendererBase], Bbox]
  124. ) -> None: ...
  125. def get_axes_locator(self) -> Callable[[_AxesBase, RendererBase], Bbox]: ...
  126. def sharex(self, other: _AxesBase) -> None: ...
  127. def sharey(self, other: _AxesBase) -> None: ...
  128. def clear(self) -> None: ...
  129. def cla(self) -> None: ...
  130. class ArtistList(Sequence[_T]):
  131. def __init__(
  132. self,
  133. axes: _AxesBase,
  134. prop_name: str,
  135. valid_types: type | Iterable[type] | None = ...,
  136. invalid_types: type | Iterable[type] | None = ...,
  137. ) -> None: ...
  138. def __len__(self) -> int: ...
  139. def __iter__(self) -> Iterator[_T]: ...
  140. @overload
  141. def __getitem__(self, key: int) -> _T: ...
  142. @overload
  143. def __getitem__(self, key: slice) -> list[_T]: ...
  144. @overload
  145. def __add__(self, other: _AxesBase.ArtistList[_T]) -> list[_T]: ...
  146. @overload
  147. def __add__(self, other: list[Any]) -> list[Any]: ...
  148. @overload
  149. def __add__(self, other: tuple[Any]) -> tuple[Any]: ...
  150. @overload
  151. def __radd__(self, other: _AxesBase.ArtistList[_T]) -> list[_T]: ...
  152. @overload
  153. def __radd__(self, other: list[Any]) -> list[Any]: ...
  154. @overload
  155. def __radd__(self, other: tuple[Any]) -> tuple[Any]: ...
  156. @property
  157. def artists(self) -> _AxesBase.ArtistList[Artist]: ...
  158. @property
  159. def collections(self) -> _AxesBase.ArtistList[Collection]: ...
  160. @property
  161. def images(self) -> _AxesBase.ArtistList[AxesImage]: ...
  162. @property
  163. def lines(self) -> _AxesBase.ArtistList[Line2D]: ...
  164. @property
  165. def patches(self) -> _AxesBase.ArtistList[Patch]: ...
  166. @property
  167. def tables(self) -> _AxesBase.ArtistList[Table]: ...
  168. @property
  169. def texts(self) -> _AxesBase.ArtistList[Text]: ...
  170. def get_facecolor(self) -> ColorType: ...
  171. def set_facecolor(self, color: ColorType | None) -> None: ...
  172. @overload
  173. def set_prop_cycle(self, cycler: Cycler | None) -> None: ...
  174. @overload
  175. def set_prop_cycle(self, label: str, values: Iterable[Any]) -> None: ...
  176. @overload
  177. def set_prop_cycle(self, **kwargs: Iterable[Any]) -> None: ...
  178. def get_aspect(self) -> float | Literal["auto"]: ...
  179. def set_aspect(
  180. self,
  181. aspect: float | Literal["auto", "equal"],
  182. adjustable: Literal["box", "datalim"] | None = ...,
  183. anchor: str | tuple[float, float] | None = ...,
  184. share: bool = ...,
  185. ) -> None: ...
  186. def get_adjustable(self) -> Literal["box", "datalim"]: ...
  187. def set_adjustable(
  188. self, adjustable: Literal["box", "datalim"], share: bool = ...
  189. ) -> None: ...
  190. def get_box_aspect(self) -> float | None: ...
  191. def set_box_aspect(self, aspect: float | None = ...) -> None: ...
  192. def get_anchor(self) -> str | tuple[float, float]: ...
  193. def set_anchor(
  194. self, anchor: str | tuple[float, float], share: bool = ...
  195. ) -> None: ...
  196. def get_data_ratio(self) -> float: ...
  197. def apply_aspect(self, position: Bbox | None = ...) -> None: ...
  198. @overload
  199. def axis(
  200. self,
  201. arg: tuple[float, float, float, float] | bool | str | None = ...,
  202. /,
  203. *,
  204. emit: bool = ...
  205. ) -> tuple[float, float, float, float]: ...
  206. @overload
  207. def axis(
  208. self,
  209. *,
  210. emit: bool = ...,
  211. xmin: float | None = ...,
  212. xmax: float | None = ...,
  213. ymin: float | None = ...,
  214. ymax: float | None = ...
  215. ) -> tuple[float, float, float, float]: ...
  216. def get_legend(self) -> Legend | None: ...
  217. def get_images(self) -> list[AxesImage]: ...
  218. def get_lines(self) -> list[Line2D]: ...
  219. def get_xaxis(self) -> XAxis: ...
  220. def get_yaxis(self) -> YAxis: ...
  221. def has_data(self) -> bool: ...
  222. def add_artist(self, a: Artist) -> Artist: ...
  223. def add_child_axes(self, ax: _AxesBase) -> _AxesBase: ...
  224. def add_collection(
  225. self, collection: Collection, autolim: bool = ...
  226. ) -> Collection: ...
  227. def add_image(self, image: AxesImage) -> AxesImage: ...
  228. def add_line(self, line: Line2D) -> Line2D: ...
  229. def add_patch(self, p: Patch) -> Patch: ...
  230. def add_table(self, tab: Table) -> Table: ...
  231. def add_container(self, container: Container) -> Container: ...
  232. def relim(self, visible_only: bool = ...) -> None: ...
  233. def update_datalim(
  234. self, xys: ArrayLike, updatex: bool = ..., updatey: bool = ...
  235. ) -> None: ...
  236. def in_axes(self, mouseevent: MouseEvent) -> bool: ...
  237. def get_autoscale_on(self) -> bool: ...
  238. def set_autoscale_on(self, b: bool) -> None: ...
  239. @property
  240. def use_sticky_edges(self) -> bool: ...
  241. @use_sticky_edges.setter
  242. def use_sticky_edges(self, b: bool) -> None: ...
  243. def get_xmargin(self) -> float: ...
  244. def get_ymargin(self) -> float: ...
  245. def set_xmargin(self, m: float) -> None: ...
  246. def set_ymargin(self, m: float) -> None: ...
  247. # Probably could be made better with overloads
  248. def margins(
  249. self,
  250. *margins: float,
  251. x: float | None = ...,
  252. y: float | None = ...,
  253. tight: bool | None = ...
  254. ) -> tuple[float, float] | None: ...
  255. def set_rasterization_zorder(self, z: float | None) -> None: ...
  256. def get_rasterization_zorder(self) -> float | None: ...
  257. def autoscale(
  258. self,
  259. enable: bool = ...,
  260. axis: Literal["both", "x", "y"] = ...,
  261. tight: bool | None = ...,
  262. ) -> None: ...
  263. def autoscale_view(
  264. self, tight: bool | None = ..., scalex: bool = ..., scaley: bool = ...
  265. ) -> None: ...
  266. def draw_artist(self, a: Artist) -> None: ...
  267. def redraw_in_frame(self) -> None: ...
  268. def get_frame_on(self) -> bool: ...
  269. def set_frame_on(self, b: bool) -> None: ...
  270. def get_axisbelow(self) -> bool | Literal["line"]: ...
  271. def set_axisbelow(self, b: bool | Literal["line"]) -> None: ...
  272. def grid(
  273. self,
  274. visible: bool | None = ...,
  275. which: Literal["major", "minor", "both"] = ...,
  276. axis: Literal["both", "x", "y"] = ...,
  277. **kwargs
  278. ) -> None: ...
  279. def ticklabel_format(
  280. self,
  281. *,
  282. axis: Literal["both", "x", "y"] = ...,
  283. style: Literal["", "sci", "scientific", "plain"] | None = ...,
  284. scilimits: tuple[int, int] | None = ...,
  285. useOffset: bool | float | None = ...,
  286. useLocale: bool | None = ...,
  287. useMathText: bool | None = ...
  288. ) -> None: ...
  289. def locator_params(
  290. self, axis: Literal["both", "x", "y"] = ..., tight: bool | None = ..., **kwargs
  291. ) -> None: ...
  292. def tick_params(self, axis: Literal["both", "x", "y"] = ..., **kwargs) -> None: ...
  293. def set_axis_off(self) -> None: ...
  294. def set_axis_on(self) -> None: ...
  295. def get_xlabel(self) -> str: ...
  296. def set_xlabel(
  297. self,
  298. xlabel: str,
  299. fontdict: dict[str, Any] | None = ...,
  300. labelpad: float | None = ...,
  301. *,
  302. loc: Literal["left", "center", "right"] | None = ...,
  303. **kwargs
  304. ) -> Text: ...
  305. def invert_xaxis(self) -> None: ...
  306. def get_xbound(self) -> tuple[float, float]: ...
  307. def set_xbound(
  308. self, lower: float | None = ..., upper: float | None = ...
  309. ) -> None: ...
  310. def get_xlim(self) -> tuple[float, float]: ...
  311. def set_xlim(
  312. self,
  313. left: float | tuple[float, float] | None = ...,
  314. right: float | None = ...,
  315. *,
  316. emit: bool = ...,
  317. auto: bool | None = ...,
  318. xmin: float | None = ...,
  319. xmax: float | None = ...
  320. ) -> tuple[float, float]: ...
  321. def get_ylabel(self) -> str: ...
  322. def set_ylabel(
  323. self,
  324. ylabel: str,
  325. fontdict: dict[str, Any] | None = ...,
  326. labelpad: float | None = ...,
  327. *,
  328. loc: Literal["bottom", "center", "top"] | None = ...,
  329. **kwargs
  330. ) -> Text: ...
  331. def invert_yaxis(self) -> None: ...
  332. def get_ybound(self) -> tuple[float, float]: ...
  333. def set_ybound(
  334. self, lower: float | None = ..., upper: float | None = ...
  335. ) -> None: ...
  336. def get_ylim(self) -> tuple[float, float]: ...
  337. def set_ylim(
  338. self,
  339. bottom: float | tuple[float, float] | None = ...,
  340. top: float | None = ...,
  341. *,
  342. emit: bool = ...,
  343. auto: bool | None = ...,
  344. ymin: float | None = ...,
  345. ymax: float | None = ...
  346. ) -> tuple[float, float]: ...
  347. def format_xdata(self, x: float) -> str: ...
  348. def format_ydata(self, y: float) -> str: ...
  349. def format_coord(self, x: float, y: float) -> str: ...
  350. def minorticks_on(self) -> None: ...
  351. def minorticks_off(self) -> None: ...
  352. def can_zoom(self) -> bool: ...
  353. def can_pan(self) -> bool: ...
  354. def get_navigate(self) -> bool: ...
  355. def set_navigate(self, b: bool) -> None: ...
  356. def get_forward_navigation_events(self) -> bool | Literal["auto"]: ...
  357. def set_forward_navigation_events(self, forward: bool | Literal["auto"]) -> None: ...
  358. def get_navigate_mode(self) -> Literal["PAN", "ZOOM"] | None: ...
  359. def set_navigate_mode(self, b: Literal["PAN", "ZOOM"] | None) -> None: ...
  360. def start_pan(self, x: float, y: float, button: MouseButton) -> None: ...
  361. def end_pan(self) -> None: ...
  362. def drag_pan(
  363. self, button: MouseButton, key: str | None, x: float, y: float
  364. ) -> None: ...
  365. def get_children(self) -> list[Artist]: ...
  366. def contains_point(self, point: tuple[int, int]) -> bool: ...
  367. def get_default_bbox_extra_artists(self) -> list[Artist]: ...
  368. def get_tightbbox(
  369. self,
  370. renderer: RendererBase | None = ...,
  371. *,
  372. call_axes_locator: bool = ...,
  373. bbox_extra_artists: Sequence[Artist] | None = ...,
  374. for_layout_only: bool = ...
  375. ) -> Bbox | None: ...
  376. def twinx(self) -> Axes: ...
  377. def twiny(self) -> Axes: ...
  378. def get_shared_x_axes(self) -> cbook.GrouperView: ...
  379. def get_shared_y_axes(self) -> cbook.GrouperView: ...
  380. def label_outer(self, remove_inner_ticks: bool = ...) -> None: ...
  381. # The methods underneath this line are added via the `_axis_method_wrapper` class
  382. # Initially they are set to an object, but that object uses `__set_name__` to override
  383. # itself with a method modified from the Axis methods for the x or y Axis.
  384. # As such, they are typed according to the resultant method rather than as that object.
  385. def get_xgridlines(self) -> list[Line2D]: ...
  386. def get_xticklines(self, minor: bool = ...) -> list[Line2D]: ...
  387. def get_ygridlines(self) -> list[Line2D]: ...
  388. def get_yticklines(self, minor: bool = ...) -> list[Line2D]: ...
  389. def _sci(self, im: ColorizingArtist) -> None: ...
  390. def get_autoscalex_on(self) -> bool: ...
  391. def get_autoscaley_on(self) -> bool: ...
  392. def set_autoscalex_on(self, b: bool) -> None: ...
  393. def set_autoscaley_on(self, b: bool) -> None: ...
  394. def xaxis_inverted(self) -> bool: ...
  395. def get_xscale(self) -> str: ...
  396. def set_xscale(self, value: str | ScaleBase, **kwargs) -> None: ...
  397. def get_xticks(self, *, minor: bool = ...) -> np.ndarray: ...
  398. def set_xticks(
  399. self,
  400. ticks: ArrayLike,
  401. labels: Iterable[str] | None = ...,
  402. *,
  403. minor: bool = ...,
  404. **kwargs
  405. ) -> list[Tick]: ...
  406. def get_xmajorticklabels(self) -> list[Text]: ...
  407. def get_xminorticklabels(self) -> list[Text]: ...
  408. def get_xticklabels(
  409. self, minor: bool = ..., which: Literal["major", "minor", "both"] | None = ...
  410. ) -> list[Text]: ...
  411. def set_xticklabels(
  412. self,
  413. labels: Iterable[str | Text],
  414. *,
  415. minor: bool = ...,
  416. fontdict: dict[str, Any] | None = ...,
  417. **kwargs
  418. ) -> list[Text]: ...
  419. def yaxis_inverted(self) -> bool: ...
  420. def get_yscale(self) -> str: ...
  421. def set_yscale(self, value: str | ScaleBase, **kwargs) -> None: ...
  422. def get_yticks(self, *, minor: bool = ...) -> np.ndarray: ...
  423. def set_yticks(
  424. self,
  425. ticks: ArrayLike,
  426. labels: Iterable[str] | None = ...,
  427. *,
  428. minor: bool = ...,
  429. **kwargs
  430. ) -> list[Tick]: ...
  431. def get_ymajorticklabels(self) -> list[Text]: ...
  432. def get_yminorticklabels(self) -> list[Text]: ...
  433. def get_yticklabels(
  434. self, minor: bool = ..., which: Literal["major", "minor", "both"] | None = ...
  435. ) -> list[Text]: ...
  436. def set_yticklabels(
  437. self,
  438. labels: Iterable[str | Text],
  439. *,
  440. minor: bool = ...,
  441. fontdict: dict[str, Any] | None = ...,
  442. **kwargs
  443. ) -> list[Text]: ...
  444. def xaxis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...
  445. def yaxis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...