axis.pyi 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. from collections.abc import Callable, Iterable, Sequence
  2. import datetime
  3. from typing import Any, Literal, overload
  4. from typing_extensions import Self # < Py 3.11
  5. import numpy as np
  6. from numpy.typing import ArrayLike
  7. import matplotlib.artist as martist
  8. from matplotlib import cbook
  9. from matplotlib.axes import Axes
  10. from matplotlib.backend_bases import RendererBase
  11. from matplotlib.lines import Line2D
  12. from matplotlib.text import Text
  13. from matplotlib.ticker import Locator, Formatter
  14. from matplotlib.transforms import Transform, Bbox
  15. from matplotlib.typing import ColorType
  16. from matplotlib.units import ConversionInterface
  17. GRIDLINE_INTERPOLATION_STEPS: int
  18. class Tick(martist.Artist):
  19. axes: Axes
  20. tick1line: Line2D
  21. tick2line: Line2D
  22. gridline: Line2D
  23. label1: Text
  24. label2: Text
  25. def __init__(
  26. self,
  27. axes: Axes,
  28. loc: float,
  29. *,
  30. size: float | None = ...,
  31. width: float | None = ...,
  32. color: ColorType | None = ...,
  33. tickdir: Literal["in", "inout", "out"] | None = ...,
  34. pad: float | None = ...,
  35. labelsize: float | None = ...,
  36. labelcolor: ColorType | None = ...,
  37. labelfontfamily: str | Sequence[str] | None = ...,
  38. zorder: float | None = ...,
  39. gridOn: bool | None = ...,
  40. tick1On: bool = ...,
  41. tick2On: bool = ...,
  42. label1On: bool = ...,
  43. label2On: bool = ...,
  44. major: bool = ...,
  45. labelrotation: float = ...,
  46. grid_color: ColorType | None = ...,
  47. grid_linestyle: str | None = ...,
  48. grid_linewidth: float | None = ...,
  49. grid_alpha: float | None = ...,
  50. **kwargs
  51. ) -> None: ...
  52. def get_tickdir(self) -> Literal["in", "inout", "out"]: ...
  53. def get_tick_padding(self) -> float: ...
  54. def get_children(self) -> list[martist.Artist]: ...
  55. stale: bool
  56. def set_pad(self, val: float) -> None: ...
  57. def get_pad(self) -> None: ...
  58. def get_loc(self) -> float: ...
  59. def set_url(self, url: str | None) -> None: ...
  60. def get_view_interval(self) -> ArrayLike: ...
  61. def update_position(self, loc: float) -> None: ...
  62. class XTick(Tick):
  63. __name__: str
  64. def __init__(self, *args, **kwargs) -> None: ...
  65. stale: bool
  66. def update_position(self, loc: float) -> None: ...
  67. def get_view_interval(self) -> np.ndarray: ...
  68. class YTick(Tick):
  69. __name__: str
  70. def __init__(self, *args, **kwargs) -> None: ...
  71. stale: bool
  72. def update_position(self, loc: float) -> None: ...
  73. def get_view_interval(self) -> np.ndarray: ...
  74. class Ticker:
  75. def __init__(self) -> None: ...
  76. @property
  77. def locator(self) -> Locator | None: ...
  78. @locator.setter
  79. def locator(self, locator: Locator) -> None: ...
  80. @property
  81. def formatter(self) -> Formatter | None: ...
  82. @formatter.setter
  83. def formatter(self, formatter: Formatter) -> None: ...
  84. class _LazyTickList:
  85. def __init__(self, major: bool) -> None: ...
  86. @overload
  87. def __get__(self, instance: None, owner: None) -> Self: ...
  88. @overload
  89. def __get__(self, instance: Axis, owner: type[Axis]) -> list[Tick]: ...
  90. class Axis(martist.Artist):
  91. OFFSETTEXTPAD: int
  92. isDefault_label: bool
  93. axes: Axes
  94. major: Ticker
  95. minor: Ticker
  96. callbacks: cbook.CallbackRegistry
  97. label: Text
  98. offsetText: Text
  99. labelpad: float
  100. pickradius: float
  101. def __init__(self, axes, *, pickradius: float = ...,
  102. clear: bool = ...) -> None: ...
  103. @property
  104. def isDefault_majloc(self) -> bool: ...
  105. @isDefault_majloc.setter
  106. def isDefault_majloc(self, value: bool) -> None: ...
  107. @property
  108. def isDefault_majfmt(self) -> bool: ...
  109. @isDefault_majfmt.setter
  110. def isDefault_majfmt(self, value: bool) -> None: ...
  111. @property
  112. def isDefault_minloc(self) -> bool: ...
  113. @isDefault_minloc.setter
  114. def isDefault_minloc(self, value: bool) -> None: ...
  115. @property
  116. def isDefault_minfmt(self) -> bool: ...
  117. @isDefault_minfmt.setter
  118. def isDefault_minfmt(self, value: bool) -> None: ...
  119. majorTicks: _LazyTickList
  120. minorTicks: _LazyTickList
  121. def get_remove_overlapping_locs(self) -> bool: ...
  122. def set_remove_overlapping_locs(self, val: bool) -> None: ...
  123. @property
  124. def remove_overlapping_locs(self) -> bool: ...
  125. @remove_overlapping_locs.setter
  126. def remove_overlapping_locs(self, val: bool) -> None: ...
  127. stale: bool
  128. def set_label_coords(
  129. self, x: float, y: float, transform: Transform | None = ...
  130. ) -> None: ...
  131. def get_transform(self) -> Transform: ...
  132. def get_scale(self) -> str: ...
  133. def limit_range_for_scale(
  134. self, vmin: float, vmax: float
  135. ) -> tuple[float, float]: ...
  136. def get_children(self) -> list[martist.Artist]: ...
  137. # TODO units
  138. converter: Any
  139. units: Any
  140. def clear(self) -> None: ...
  141. def reset_ticks(self) -> None: ...
  142. def minorticks_on(self) -> None: ...
  143. def minorticks_off(self) -> None: ...
  144. def set_tick_params(
  145. self,
  146. which: Literal["major", "minor", "both"] = ...,
  147. reset: bool = ...,
  148. **kwargs
  149. ) -> None: ...
  150. def get_tick_params(
  151. self, which: Literal["major", "minor"] = ...
  152. ) -> dict[str, Any]: ...
  153. def get_view_interval(self) -> tuple[float, float]: ...
  154. def set_view_interval(
  155. self, vmin: float, vmax: float, ignore: bool = ...
  156. ) -> None: ...
  157. def get_data_interval(self) -> tuple[float, float]: ...
  158. def set_data_interval(
  159. self, vmin: float, vmax: float, ignore: bool = ...
  160. ) -> None: ...
  161. def get_inverted(self) -> bool: ...
  162. def set_inverted(self, inverted: bool) -> None: ...
  163. def set_default_intervals(self) -> None: ...
  164. def get_tightbbox(
  165. self, renderer: RendererBase | None = ..., *, for_layout_only: bool = ...
  166. ) -> Bbox | None: ...
  167. def get_tick_padding(self) -> float: ...
  168. def get_gridlines(self) -> list[Line2D]: ...
  169. def get_label(self) -> Text: ...
  170. def get_offset_text(self) -> Text: ...
  171. def get_pickradius(self) -> float: ...
  172. def get_majorticklabels(self) -> list[Text]: ...
  173. def get_minorticklabels(self) -> list[Text]: ...
  174. def get_ticklabels(
  175. self, minor: bool = ..., which: Literal["major", "minor", "both"] | None = ...
  176. ) -> list[Text]: ...
  177. def get_majorticklines(self) -> list[Line2D]: ...
  178. def get_minorticklines(self) -> list[Line2D]: ...
  179. def get_ticklines(self, minor: bool = ...) -> list[Line2D]: ...
  180. def get_majorticklocs(self) -> np.ndarray: ...
  181. def get_minorticklocs(self) -> np.ndarray: ...
  182. def get_ticklocs(self, *, minor: bool = ...) -> np.ndarray: ...
  183. def get_ticks_direction(self, minor: bool = ...) -> np.ndarray: ...
  184. def get_label_text(self) -> str: ...
  185. def get_major_locator(self) -> Locator: ...
  186. def get_minor_locator(self) -> Locator: ...
  187. def get_major_formatter(self) -> Formatter: ...
  188. def get_minor_formatter(self) -> Formatter: ...
  189. def get_major_ticks(self, numticks: int | None = ...) -> list[Tick]: ...
  190. def get_minor_ticks(self, numticks: int | None = ...) -> list[Tick]: ...
  191. def grid(
  192. self,
  193. visible: bool | None = ...,
  194. which: Literal["major", "minor", "both"] = ...,
  195. **kwargs
  196. ) -> None: ...
  197. # TODO units
  198. def update_units(self, data): ...
  199. def have_units(self) -> bool: ...
  200. def convert_units(self, x): ...
  201. def get_converter(self) -> ConversionInterface | None: ...
  202. def set_converter(self, converter: ConversionInterface) -> None: ...
  203. def set_units(self, u) -> None: ...
  204. def get_units(self): ...
  205. def set_label_text(
  206. self, label: str, fontdict: dict[str, Any] | None = ..., **kwargs
  207. ) -> Text: ...
  208. def set_major_formatter(
  209. self, formatter: Formatter | str | Callable[[float, float], str]
  210. ) -> None: ...
  211. def set_minor_formatter(
  212. self, formatter: Formatter | str | Callable[[float, float], str]
  213. ) -> None: ...
  214. def set_major_locator(self, locator: Locator) -> None: ...
  215. def set_minor_locator(self, locator: Locator) -> None: ...
  216. def set_pickradius(self, pickradius: float) -> None: ...
  217. def set_ticklabels(
  218. self,
  219. labels: Iterable[str | Text],
  220. *,
  221. minor: bool = ...,
  222. fontdict: dict[str, Any] | None = ...,
  223. **kwargs
  224. ) -> list[Text]: ...
  225. def set_ticks(
  226. self,
  227. ticks: ArrayLike,
  228. labels: Iterable[str] | None = ...,
  229. *,
  230. minor: bool = ...,
  231. **kwargs
  232. ) -> list[Tick]: ...
  233. def axis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...
  234. def get_tick_space(self) -> int: ...
  235. def get_label_position(self) -> Literal["top", "bottom"]: ...
  236. def set_label_position(
  237. self, position: Literal["top", "bottom", "left", "right"]
  238. ) -> None: ...
  239. def get_minpos(self) -> float: ...
  240. class XAxis(Axis):
  241. __name__: str
  242. axis_name: str
  243. def __init__(self, *args, **kwargs) -> None: ...
  244. label_position: Literal["bottom", "top"]
  245. stale: bool
  246. def set_label_position(self, position: Literal["bottom", "top"]) -> None: ... # type: ignore[override]
  247. def set_ticks_position(
  248. self, position: Literal["top", "bottom", "both", "default", "none"]
  249. ) -> None: ...
  250. def tick_top(self) -> None: ...
  251. def tick_bottom(self) -> None: ...
  252. def get_ticks_position(self) -> Literal["top", "bottom", "default", "unknown"]: ...
  253. def get_tick_space(self) -> int: ...
  254. class YAxis(Axis):
  255. __name__: str
  256. axis_name: str
  257. def __init__(self, *args, **kwargs) -> None: ...
  258. label_position: Literal["left", "right"]
  259. stale: bool
  260. def set_label_position(self, position: Literal["left", "right"]) -> None: ... # type: ignore[override]
  261. def set_offset_position(self, position: Literal["left", "right"]) -> None: ...
  262. def set_ticks_position(
  263. self, position: Literal["left", "right", "both", "default", "none"]
  264. ) -> None: ...
  265. def tick_right(self) -> None: ...
  266. def tick_left(self) -> None: ...
  267. def get_ticks_position(self) -> Literal["left", "right", "default", "unknown"]: ...
  268. def get_tick_space(self) -> int: ...