axis.pyi 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. from collections.abc import Callable, Iterable, Sequence
  2. import datetime
  3. from typing import Any, Literal, overload
  4. import numpy as np
  5. from numpy.typing import ArrayLike
  6. import matplotlib.artist as martist
  7. from matplotlib import cbook
  8. from matplotlib.axes import Axes
  9. from matplotlib.backend_bases import RendererBase
  10. from matplotlib.lines import Line2D
  11. from matplotlib.text import Text
  12. from matplotlib.ticker import Locator, Formatter
  13. from matplotlib.transforms import Transform, Bbox
  14. from matplotlib.typing import ColorType
  15. GRIDLINE_INTERPOLATION_STEPS: int
  16. class Tick(martist.Artist):
  17. axes: Axes
  18. tick1line: Line2D
  19. tick2line: Line2D
  20. gridline: Line2D
  21. label1: Text
  22. label2: Text
  23. def __init__(
  24. self,
  25. axes: Axes,
  26. loc: float,
  27. *,
  28. size: float | None = ...,
  29. width: float | None = ...,
  30. color: ColorType | None = ...,
  31. tickdir: Literal["in", "inout", "out"] | None = ...,
  32. pad: float | None = ...,
  33. labelsize: float | None = ...,
  34. labelcolor: ColorType | None = ...,
  35. labelfontfamily: str | Sequence[str] | None = ...,
  36. zorder: float | None = ...,
  37. gridOn: bool | None = ...,
  38. tick1On: bool = ...,
  39. tick2On: bool = ...,
  40. label1On: bool = ...,
  41. label2On: bool = ...,
  42. major: bool = ...,
  43. labelrotation: float = ...,
  44. grid_color: ColorType | None = ...,
  45. grid_linestyle: str | None = ...,
  46. grid_linewidth: float | None = ...,
  47. grid_alpha: float | None = ...,
  48. **kwargs
  49. ) -> None: ...
  50. def get_tickdir(self) -> Literal["in", "inout", "out"]: ...
  51. def get_tick_padding(self) -> float: ...
  52. def get_children(self) -> list[martist.Artist]: ...
  53. stale: bool
  54. def set_pad(self, val: float) -> None: ...
  55. def get_pad(self) -> None: ...
  56. def get_loc(self) -> float: ...
  57. def set_label1(self, s: object) -> None: ...
  58. def set_label(self, s: object) -> None: ...
  59. def set_label2(self, s: object) -> None: ...
  60. def set_url(self, url: str | None) -> None: ...
  61. def get_view_interval(self) -> ArrayLike: ...
  62. def update_position(self, loc: float) -> None: ...
  63. class XTick(Tick):
  64. __name__: str
  65. def __init__(self, *args, **kwargs) -> None: ...
  66. stale: bool
  67. def update_position(self, loc: float) -> None: ...
  68. def get_view_interval(self) -> np.ndarray: ...
  69. class YTick(Tick):
  70. __name__: str
  71. def __init__(self, *args, **kwargs) -> None: ...
  72. stale: bool
  73. def update_position(self, loc: float) -> None: ...
  74. def get_view_interval(self) -> np.ndarray: ...
  75. class Ticker:
  76. def __init__(self) -> None: ...
  77. @property
  78. def locator(self) -> Locator | None: ...
  79. @locator.setter
  80. def locator(self, locator: Locator) -> None: ...
  81. @property
  82. def formatter(self) -> Formatter | None: ...
  83. @formatter.setter
  84. def formatter(self, formatter: Formatter) -> None: ...
  85. class _LazyTickList:
  86. def __init__(self, major: bool) -> None: ...
  87. # Replace return with Self when py3.9 is dropped
  88. @overload
  89. def __get__(self, instance: None, owner: None) -> _LazyTickList: ...
  90. @overload
  91. def __get__(self, instance: Axis, owner: type[Axis]) -> list[Tick]: ...
  92. class Axis(martist.Artist):
  93. OFFSETTEXTPAD: int
  94. isDefault_label: bool
  95. axes: Axes
  96. major: Ticker
  97. minor: Ticker
  98. callbacks: cbook.CallbackRegistry
  99. label: Text
  100. offsetText: Text
  101. labelpad: float
  102. pickradius: float
  103. def __init__(self, axes, *, pickradius: float = ...,
  104. clear: bool = ...) -> None: ...
  105. @property
  106. def isDefault_majloc(self) -> bool: ...
  107. @isDefault_majloc.setter
  108. def isDefault_majloc(self, value: bool) -> None: ...
  109. @property
  110. def isDefault_majfmt(self) -> bool: ...
  111. @isDefault_majfmt.setter
  112. def isDefault_majfmt(self, value: bool) -> None: ...
  113. @property
  114. def isDefault_minloc(self) -> bool: ...
  115. @isDefault_minloc.setter
  116. def isDefault_minloc(self, value: bool) -> None: ...
  117. @property
  118. def isDefault_minfmt(self) -> bool: ...
  119. @isDefault_minfmt.setter
  120. def isDefault_minfmt(self, value: bool) -> None: ...
  121. majorTicks: _LazyTickList
  122. minorTicks: _LazyTickList
  123. def get_remove_overlapping_locs(self) -> bool: ...
  124. def set_remove_overlapping_locs(self, val: bool) -> None: ...
  125. @property
  126. def remove_overlapping_locs(self) -> bool: ...
  127. @remove_overlapping_locs.setter
  128. def remove_overlapping_locs(self, val: bool) -> None: ...
  129. stale: bool
  130. def set_label_coords(
  131. self, x: float, y: float, transform: Transform | None = ...
  132. ) -> None: ...
  133. def get_transform(self) -> Transform: ...
  134. def get_scale(self) -> str: ...
  135. def limit_range_for_scale(
  136. self, vmin: float, vmax: float
  137. ) -> tuple[float, float]: ...
  138. def get_children(self) -> list[martist.Artist]: ...
  139. # TODO units
  140. converter: Any
  141. units: Any
  142. def clear(self) -> None: ...
  143. def reset_ticks(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 set_units(self, u) -> None: ...
  202. def get_units(self): ...
  203. def set_label_text(
  204. self, label: str, fontdict: dict[str, Any] | None = ..., **kwargs
  205. ) -> Text: ...
  206. def set_major_formatter(
  207. self, formatter: Formatter | str | Callable[[float, float], str]
  208. ) -> None: ...
  209. def set_minor_formatter(
  210. self, formatter: Formatter | str | Callable[[float, float], str]
  211. ) -> None: ...
  212. def set_major_locator(self, locator: Locator) -> None: ...
  213. def set_minor_locator(self, locator: Locator) -> None: ...
  214. def set_pickradius(self, pickradius: float) -> None: ...
  215. def set_ticklabels(
  216. self,
  217. labels: Iterable[str | Text],
  218. *,
  219. minor: bool = ...,
  220. fontdict: dict[str, Any] | None = ...,
  221. **kwargs
  222. ) -> list[Text]: ...
  223. def set_ticks(
  224. self,
  225. ticks: ArrayLike,
  226. labels: Iterable[str] | None = ...,
  227. *,
  228. minor: bool = ...,
  229. **kwargs
  230. ) -> list[Tick]: ...
  231. def axis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...
  232. def get_tick_space(self) -> int: ...
  233. def get_label_position(self) -> Literal["top", "bottom"]: ...
  234. def set_label_position(
  235. self, position: Literal["top", "bottom", "left", "right"]
  236. ) -> None: ...
  237. def get_minpos(self) -> float: ...
  238. class XAxis(Axis):
  239. __name__: str
  240. axis_name: str
  241. def __init__(self, *args, **kwargs) -> None: ...
  242. label_position: Literal["bottom", "top"]
  243. stale: bool
  244. def set_label_position(self, position: Literal["bottom", "top"]) -> None: ... # type: ignore[override]
  245. def set_ticks_position(
  246. self, position: Literal["top", "bottom", "both", "default", "none"]
  247. ) -> None: ...
  248. def tick_top(self) -> None: ...
  249. def tick_bottom(self) -> None: ...
  250. def get_ticks_position(self) -> Literal["top", "bottom", "default", "unknown"]: ...
  251. def get_tick_space(self) -> int: ...
  252. class YAxis(Axis):
  253. __name__: str
  254. axis_name: str
  255. def __init__(self, *args, **kwargs) -> None: ...
  256. label_position: Literal["left", "right"]
  257. stale: bool
  258. def set_label_position(self, position: Literal["left", "right"]) -> None: ... # type: ignore[override]
  259. def set_offset_position(self, position: Literal["left", "right"]) -> None: ...
  260. def set_ticks_position(
  261. self, position: Literal["left", "right", "both", "default", "none"]
  262. ) -> None: ...
  263. def tick_right(self) -> None: ...
  264. def tick_left(self) -> None: ...
  265. def get_ticks_position(self) -> Literal["left", "right", "default", "unknown"]: ...
  266. def get_tick_space(self) -> int: ...