legend_handler.pyi 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. from collections.abc import Callable, Sequence
  2. from matplotlib.artist import Artist
  3. from matplotlib.legend import Legend
  4. from matplotlib.offsetbox import OffsetBox
  5. from matplotlib.transforms import Transform
  6. from typing import TypeVar
  7. from numpy.typing import ArrayLike
  8. def update_from_first_child(tgt: Artist, src: Artist) -> None: ...
  9. class HandlerBase:
  10. def __init__(
  11. self,
  12. xpad: float = ...,
  13. ypad: float = ...,
  14. update_func: Callable[[Artist, Artist], None] | None = ...,
  15. ) -> None: ...
  16. def update_prop(
  17. self, legend_handle: Artist, orig_handle: Artist, legend: Legend
  18. ) -> None: ...
  19. def adjust_drawing_area(
  20. self,
  21. legend: Legend,
  22. orig_handle: Artist,
  23. xdescent: float,
  24. ydescent: float,
  25. width: float,
  26. height: float,
  27. fontsize: float,
  28. ) -> tuple[float, float, float, float]: ...
  29. def legend_artist(
  30. self, legend: Legend, orig_handle: Artist, fontsize: float, handlebox: OffsetBox
  31. ) -> Artist: ...
  32. def create_artists(
  33. self,
  34. legend: Legend,
  35. orig_handle: Artist,
  36. xdescent: float,
  37. ydescent: float,
  38. width: float,
  39. height: float,
  40. fontsize: float,
  41. trans: Transform,
  42. ) -> Sequence[Artist]: ...
  43. class HandlerNpoints(HandlerBase):
  44. def __init__(
  45. self, marker_pad: float = ..., numpoints: int | None = ..., **kwargs
  46. ) -> None: ...
  47. def get_numpoints(self, legend: Legend) -> int | None: ...
  48. def get_xdata(
  49. self,
  50. legend: Legend,
  51. xdescent: float,
  52. ydescent: float,
  53. width: float,
  54. height: float,
  55. fontsize: float,
  56. ) -> tuple[ArrayLike, ArrayLike]: ...
  57. class HandlerNpointsYoffsets(HandlerNpoints):
  58. def __init__(
  59. self,
  60. numpoints: int | None = ...,
  61. yoffsets: Sequence[float] | None = ...,
  62. **kwargs
  63. ) -> None: ...
  64. def get_ydata(
  65. self,
  66. legend: Legend,
  67. xdescent: float,
  68. ydescent: float,
  69. width: float,
  70. height: float,
  71. fontsize: float,
  72. ) -> ArrayLike: ...
  73. class HandlerLine2DCompound(HandlerNpoints):
  74. def create_artists(
  75. self,
  76. legend: Legend,
  77. orig_handle: Artist,
  78. xdescent: float,
  79. ydescent: float,
  80. width: float,
  81. height: float,
  82. fontsize: float,
  83. trans: Transform,
  84. ) -> Sequence[Artist]: ...
  85. class HandlerLine2D(HandlerNpoints):
  86. def create_artists(
  87. self,
  88. legend: Legend,
  89. orig_handle: Artist,
  90. xdescent: float,
  91. ydescent: float,
  92. width: float,
  93. height: float,
  94. fontsize: float,
  95. trans: Transform,
  96. ) -> Sequence[Artist]: ...
  97. class HandlerPatch(HandlerBase):
  98. def __init__(self, patch_func: Callable | None = ..., **kwargs) -> None: ...
  99. def create_artists(
  100. self,
  101. legend: Legend,
  102. orig_handle: Artist,
  103. xdescent: float,
  104. ydescent: float,
  105. width: float,
  106. height: float,
  107. fontsize: float,
  108. trans: Transform,
  109. ) -> Sequence[Artist]: ...
  110. class HandlerStepPatch(HandlerBase):
  111. def create_artists(
  112. self,
  113. legend: Legend,
  114. orig_handle: Artist,
  115. xdescent: float,
  116. ydescent: float,
  117. width: float,
  118. height: float,
  119. fontsize: float,
  120. trans: Transform,
  121. ) -> Sequence[Artist]: ...
  122. class HandlerLineCollection(HandlerLine2D):
  123. def get_numpoints(self, legend: Legend) -> int: ...
  124. def create_artists(
  125. self,
  126. legend: Legend,
  127. orig_handle: Artist,
  128. xdescent: float,
  129. ydescent: float,
  130. width: float,
  131. height: float,
  132. fontsize: float,
  133. trans: Transform,
  134. ) -> Sequence[Artist]: ...
  135. _T = TypeVar("_T", bound=Artist)
  136. class HandlerRegularPolyCollection(HandlerNpointsYoffsets):
  137. def __init__(
  138. self,
  139. yoffsets: Sequence[float] | None = ...,
  140. sizes: Sequence[float] | None = ...,
  141. **kwargs
  142. ) -> None: ...
  143. def get_numpoints(self, legend: Legend) -> int: ...
  144. def get_sizes(
  145. self,
  146. legend: Legend,
  147. orig_handle: Artist,
  148. xdescent: float,
  149. ydescent: float,
  150. width: float,
  151. height: float,
  152. fontsize: float,
  153. ) -> Sequence[float]: ...
  154. def update_prop(
  155. self, legend_handle, orig_handle: Artist, legend: Legend
  156. ) -> None: ...
  157. def create_collection(
  158. self,
  159. orig_handle: _T,
  160. sizes: Sequence[float] | None,
  161. offsets: Sequence[float] | None,
  162. offset_transform: Transform,
  163. ) -> _T: ...
  164. def create_artists(
  165. self,
  166. legend: Legend,
  167. orig_handle: Artist,
  168. xdescent: float,
  169. ydescent: float,
  170. width: float,
  171. height: float,
  172. fontsize: float,
  173. trans: Transform,
  174. ) -> Sequence[Artist]: ...
  175. class HandlerPathCollection(HandlerRegularPolyCollection):
  176. def create_collection(
  177. self,
  178. orig_handle: _T,
  179. sizes: Sequence[float] | None,
  180. offsets: Sequence[float] | None,
  181. offset_transform: Transform,
  182. ) -> _T: ...
  183. class HandlerCircleCollection(HandlerRegularPolyCollection):
  184. def create_collection(
  185. self,
  186. orig_handle: _T,
  187. sizes: Sequence[float] | None,
  188. offsets: Sequence[float] | None,
  189. offset_transform: Transform,
  190. ) -> _T: ...
  191. class HandlerErrorbar(HandlerLine2D):
  192. def __init__(
  193. self,
  194. xerr_size: float = ...,
  195. yerr_size: float | None = ...,
  196. marker_pad: float = ...,
  197. numpoints: int | None = ...,
  198. **kwargs
  199. ) -> None: ...
  200. def get_err_size(
  201. self,
  202. legend: Legend,
  203. xdescent: float,
  204. ydescent: float,
  205. width: float,
  206. height: float,
  207. fontsize: float,
  208. ) -> tuple[float, float]: ...
  209. def create_artists(
  210. self,
  211. legend: Legend,
  212. orig_handle: Artist,
  213. xdescent: float,
  214. ydescent: float,
  215. width: float,
  216. height: float,
  217. fontsize: float,
  218. trans: Transform,
  219. ) -> Sequence[Artist]: ...
  220. class HandlerStem(HandlerNpointsYoffsets):
  221. def __init__(
  222. self,
  223. marker_pad: float = ...,
  224. numpoints: int | None = ...,
  225. bottom: float | None = ...,
  226. yoffsets: Sequence[float] | None = ...,
  227. **kwargs
  228. ) -> None: ...
  229. def get_ydata(
  230. self,
  231. legend: Legend,
  232. xdescent: float,
  233. ydescent: float,
  234. width: float,
  235. height: float,
  236. fontsize: float,
  237. ) -> ArrayLike: ...
  238. def create_artists(
  239. self,
  240. legend: Legend,
  241. orig_handle: Artist,
  242. xdescent: float,
  243. ydescent: float,
  244. width: float,
  245. height: float,
  246. fontsize: float,
  247. trans: Transform,
  248. ) -> Sequence[Artist]: ...
  249. class HandlerTuple(HandlerBase):
  250. def __init__(
  251. self, ndivide: int | None = ..., pad: float | None = ..., **kwargs
  252. ) -> None: ...
  253. def create_artists(
  254. self,
  255. legend: Legend,
  256. orig_handle: Artist,
  257. xdescent: float,
  258. ydescent: float,
  259. width: float,
  260. height: float,
  261. fontsize: float,
  262. trans: Transform,
  263. ) -> Sequence[Artist]: ...
  264. class HandlerPolyCollection(HandlerBase):
  265. def create_artists(
  266. self,
  267. legend: Legend,
  268. orig_handle: Artist,
  269. xdescent: float,
  270. ydescent: float,
  271. width: float,
  272. height: float,
  273. fontsize: float,
  274. trans: Transform,
  275. ) -> Sequence[Artist]: ...