_base.pyi 16 KB

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