collections.pyi 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. from collections.abc import Callable, Iterable, Sequence
  2. from typing import Literal
  3. import numpy as np
  4. from numpy.typing import ArrayLike, NDArray
  5. from . import colorizer, transforms
  6. from .backend_bases import MouseEvent
  7. from .artist import Artist
  8. from .colors import Normalize, Colormap
  9. from .lines import Line2D
  10. from .path import Path
  11. from .patches import Patch
  12. from .ticker import Locator, Formatter
  13. from .tri import Triangulation
  14. from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType
  15. class Collection(colorizer.ColorizingArtist):
  16. def __init__(
  17. self,
  18. *,
  19. edgecolors: ColorType | Sequence[ColorType] | None = ...,
  20. facecolors: ColorType | Sequence[ColorType] | None = ...,
  21. linewidths: float | Sequence[float] | None = ...,
  22. linestyles: LineStyleType | Sequence[LineStyleType] = ...,
  23. capstyle: CapStyleType | None = ...,
  24. joinstyle: JoinStyleType | None = ...,
  25. antialiaseds: bool | Sequence[bool] | None = ...,
  26. offsets: tuple[float, float] | Sequence[tuple[float, float]] | None = ...,
  27. offset_transform: transforms.Transform | None = ...,
  28. norm: Normalize | None = ...,
  29. cmap: Colormap | None = ...,
  30. colorizer: colorizer.Colorizer | None = ...,
  31. pickradius: float = ...,
  32. hatch: str | None = ...,
  33. urls: Sequence[str] | None = ...,
  34. zorder: float = ...,
  35. **kwargs
  36. ) -> None: ...
  37. def get_paths(self) -> Sequence[Path]: ...
  38. def set_paths(self, paths: Sequence[Path]) -> None: ...
  39. def get_transforms(self) -> Sequence[transforms.Transform]: ...
  40. def get_offset_transform(self) -> transforms.Transform: ...
  41. def set_offset_transform(self, offset_transform: transforms.Transform) -> None: ...
  42. def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ...
  43. def set_pickradius(self, pickradius: float) -> None: ...
  44. def get_pickradius(self) -> float: ...
  45. def set_urls(self, urls: Sequence[str | None]) -> None: ...
  46. def get_urls(self) -> Sequence[str | None]: ...
  47. def set_hatch(self, hatch: str) -> None: ...
  48. def get_hatch(self) -> str: ...
  49. def set_hatch_linewidth(self, lw: float) -> None: ...
  50. def get_hatch_linewidth(self) -> float: ...
  51. def set_offsets(self, offsets: ArrayLike) -> None: ...
  52. def get_offsets(self) -> ArrayLike: ...
  53. def set_linewidth(self, lw: float | Sequence[float]) -> None: ...
  54. def set_linestyle(self, ls: LineStyleType | Sequence[LineStyleType]) -> None: ...
  55. def set_capstyle(self, cs: CapStyleType) -> None: ...
  56. def get_capstyle(self) -> Literal["butt", "projecting", "round"] | None: ...
  57. def set_joinstyle(self, js: JoinStyleType) -> None: ...
  58. def get_joinstyle(self) -> Literal["miter", "round", "bevel"] | None: ...
  59. def set_antialiased(self, aa: bool | Sequence[bool]) -> None: ...
  60. def get_antialiased(self) -> NDArray[np.bool_]: ...
  61. def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
  62. def set_facecolor(self, c: ColorType | Sequence[ColorType]) -> None: ...
  63. def get_facecolor(self) -> ColorType | Sequence[ColorType]: ...
  64. def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ...
  65. def set_edgecolor(self, c: ColorType | Sequence[ColorType]) -> None: ...
  66. def set_alpha(self, alpha: float | Sequence[float] | None) -> None: ...
  67. def get_linewidth(self) -> float | Sequence[float]: ...
  68. def get_linestyle(self) -> LineStyleType | Sequence[LineStyleType]: ...
  69. def update_scalarmappable(self) -> None: ...
  70. def get_fill(self) -> bool: ...
  71. def update_from(self, other: Artist) -> None: ...
  72. class _CollectionWithSizes(Collection):
  73. def get_sizes(self) -> np.ndarray: ...
  74. def set_sizes(self, sizes: ArrayLike | None, dpi: float = ...) -> None: ...
  75. class PathCollection(_CollectionWithSizes):
  76. def __init__(
  77. self, paths: Sequence[Path], sizes: ArrayLike | None = ..., **kwargs
  78. ) -> None: ...
  79. def set_paths(self, paths: Sequence[Path]) -> None: ...
  80. def get_paths(self) -> Sequence[Path]: ...
  81. def legend_elements(
  82. self,
  83. prop: Literal["colors", "sizes"] = ...,
  84. num: int | Literal["auto"] | ArrayLike | Locator = ...,
  85. fmt: str | Formatter | None = ...,
  86. func: Callable[[ArrayLike], ArrayLike] = ...,
  87. **kwargs,
  88. ) -> tuple[list[Line2D], list[str]]: ...
  89. class PolyCollection(_CollectionWithSizes):
  90. def __init__(
  91. self,
  92. verts: Sequence[ArrayLike],
  93. sizes: ArrayLike | None = ...,
  94. *,
  95. closed: bool = ...,
  96. **kwargs
  97. ) -> None: ...
  98. def set_verts(
  99. self, verts: Sequence[ArrayLike | Path], closed: bool = ...
  100. ) -> None: ...
  101. def set_paths(self, verts: Sequence[Path], closed: bool = ...) -> None: ...
  102. def set_verts_and_codes(
  103. self, verts: Sequence[ArrayLike | Path], codes: Sequence[int]
  104. ) -> None: ...
  105. class FillBetweenPolyCollection(PolyCollection):
  106. def __init__(
  107. self,
  108. t_direction: Literal["x", "y"],
  109. t: ArrayLike,
  110. f1: ArrayLike,
  111. f2: ArrayLike,
  112. *,
  113. where: Sequence[bool] | None = ...,
  114. interpolate: bool = ...,
  115. step: Literal["pre", "post", "mid"] | None = ...,
  116. **kwargs,
  117. ) -> None: ...
  118. def set_data(
  119. self,
  120. t: ArrayLike,
  121. f1: ArrayLike,
  122. f2: ArrayLike,
  123. *,
  124. where: Sequence[bool] | None = ...,
  125. ) -> None: ...
  126. def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ...
  127. class RegularPolyCollection(_CollectionWithSizes):
  128. def __init__(
  129. self, numsides: int, *, rotation: float = ..., sizes: ArrayLike = ..., **kwargs
  130. ) -> None: ...
  131. def get_numsides(self) -> int: ...
  132. def get_rotation(self) -> float: ...
  133. class StarPolygonCollection(RegularPolyCollection): ...
  134. class AsteriskPolygonCollection(RegularPolyCollection): ...
  135. class LineCollection(Collection):
  136. def __init__(
  137. self, segments: Sequence[ArrayLike], *, zorder: float = ..., **kwargs
  138. ) -> None: ...
  139. def set_segments(self, segments: Sequence[ArrayLike] | None) -> None: ...
  140. def set_verts(self, segments: Sequence[ArrayLike] | None) -> None: ...
  141. def set_paths(self, segments: Sequence[ArrayLike] | None) -> None: ... # type: ignore[override]
  142. def get_segments(self) -> list[np.ndarray]: ...
  143. def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
  144. def set_colors(self, c: ColorType | Sequence[ColorType]) -> None: ...
  145. def set_gapcolor(self, gapcolor: ColorType | Sequence[ColorType] | None) -> None: ...
  146. def get_color(self) -> ColorType | Sequence[ColorType]: ...
  147. def get_colors(self) -> ColorType | Sequence[ColorType]: ...
  148. def get_gapcolor(self) -> ColorType | Sequence[ColorType] | None: ...
  149. class EventCollection(LineCollection):
  150. def __init__(
  151. self,
  152. positions: ArrayLike,
  153. orientation: Literal["horizontal", "vertical"] = ...,
  154. *,
  155. lineoffset: float = ...,
  156. linelength: float = ...,
  157. linewidth: float | Sequence[float] | None = ...,
  158. color: ColorType | Sequence[ColorType] | None = ...,
  159. linestyle: LineStyleType | Sequence[LineStyleType] = ...,
  160. antialiased: bool | Sequence[bool] | None = ...,
  161. **kwargs
  162. ) -> None: ...
  163. def get_positions(self) -> list[float]: ...
  164. def set_positions(self, positions: Sequence[float] | None) -> None: ...
  165. def add_positions(self, position: Sequence[float] | None) -> None: ...
  166. def extend_positions(self, position: Sequence[float] | None) -> None: ...
  167. def append_positions(self, position: Sequence[float] | None) -> None: ...
  168. def is_horizontal(self) -> bool: ...
  169. def get_orientation(self) -> Literal["horizontal", "vertical"]: ...
  170. def switch_orientation(self) -> None: ...
  171. def set_orientation(
  172. self, orientation: Literal["horizontal", "vertical"]
  173. ) -> None: ...
  174. def get_linelength(self) -> float | Sequence[float]: ...
  175. def set_linelength(self, linelength: float | Sequence[float]) -> None: ...
  176. def get_lineoffset(self) -> float: ...
  177. def set_lineoffset(self, lineoffset: float) -> None: ...
  178. def get_linewidth(self) -> float: ...
  179. def get_linewidths(self) -> Sequence[float]: ...
  180. def get_color(self) -> ColorType: ...
  181. class CircleCollection(_CollectionWithSizes):
  182. def __init__(self, sizes: float | ArrayLike, **kwargs) -> None: ...
  183. class EllipseCollection(Collection):
  184. def __init__(
  185. self,
  186. widths: ArrayLike,
  187. heights: ArrayLike,
  188. angles: ArrayLike,
  189. *,
  190. units: Literal[
  191. "points", "inches", "dots", "width", "height", "x", "y", "xy"
  192. ] = ...,
  193. **kwargs
  194. ) -> None: ...
  195. def set_widths(self, widths: ArrayLike) -> None: ...
  196. def set_heights(self, heights: ArrayLike) -> None: ...
  197. def set_angles(self, angles: ArrayLike) -> None: ...
  198. def get_widths(self) -> ArrayLike: ...
  199. def get_heights(self) -> ArrayLike: ...
  200. def get_angles(self) -> ArrayLike: ...
  201. class PatchCollection(Collection):
  202. def __init__(
  203. self, patches: Iterable[Patch], *, match_original: bool = ..., **kwargs
  204. ) -> None: ...
  205. def set_paths(self, patches: Iterable[Patch]) -> None: ... # type: ignore[override]
  206. class TriMesh(Collection):
  207. def __init__(self, triangulation: Triangulation, **kwargs) -> None: ...
  208. def get_paths(self) -> list[Path]: ...
  209. # Parent class has an argument, perhaps add a noop arg?
  210. def set_paths(self) -> None: ... # type: ignore[override]
  211. @staticmethod
  212. def convert_mesh_to_paths(tri: Triangulation) -> list[Path]: ...
  213. class _MeshData:
  214. def __init__(
  215. self,
  216. coordinates: ArrayLike,
  217. *,
  218. shading: Literal["flat", "gouraud"] = ...,
  219. ) -> None: ...
  220. def set_array(self, A: ArrayLike | None) -> None: ...
  221. def get_coordinates(self) -> ArrayLike: ...
  222. def get_facecolor(self) -> ColorType | Sequence[ColorType]: ...
  223. def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ...
  224. class QuadMesh(_MeshData, Collection):
  225. def __init__(
  226. self,
  227. coordinates: ArrayLike,
  228. *,
  229. antialiased: bool = ...,
  230. shading: Literal["flat", "gouraud"] = ...,
  231. **kwargs
  232. ) -> None: ...
  233. def get_paths(self) -> list[Path]: ...
  234. # Parent class has an argument, perhaps add a noop arg?
  235. def set_paths(self) -> None: ... # type: ignore[override]
  236. def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ...
  237. def get_cursor_data(self, event: MouseEvent) -> float: ...
  238. class PolyQuadMesh(_MeshData, PolyCollection):
  239. def __init__(
  240. self,
  241. coordinates: ArrayLike,
  242. **kwargs
  243. ) -> None: ...