offsetbox.pyi 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. import matplotlib.artist as martist
  2. from matplotlib.backend_bases import RendererBase, Event, FigureCanvasBase
  3. from matplotlib.colors import Colormap, Normalize
  4. import matplotlib.text as mtext
  5. from matplotlib.figure import Figure, SubFigure
  6. from matplotlib.font_manager import FontProperties
  7. from matplotlib.image import BboxImage
  8. from matplotlib.patches import FancyArrowPatch, FancyBboxPatch
  9. from matplotlib.transforms import Bbox, BboxBase, Transform
  10. from matplotlib.typing import CoordsType
  11. import numpy as np
  12. from numpy.typing import ArrayLike
  13. from collections.abc import Callable, Sequence
  14. from typing import Any, Literal, overload
  15. DEBUG: bool
  16. def _get_packed_offsets(
  17. widths: Sequence[float],
  18. total: float | None,
  19. sep: float | None,
  20. mode: Literal["fixed", "expand", "equal"] = ...,
  21. ) -> tuple[float, np.ndarray]: ...
  22. class OffsetBox(martist.Artist):
  23. width: float | None
  24. height: float | None
  25. def __init__(self, *args, **kwargs) -> None: ...
  26. def set_figure(self, fig: Figure | SubFigure) -> None: ...
  27. def set_offset(
  28. self,
  29. xy: tuple[float, float]
  30. | Callable[[float, float, float, float, RendererBase], tuple[float, float]],
  31. ) -> None: ...
  32. @overload
  33. def get_offset(self, bbox: Bbox, renderer: RendererBase) -> tuple[float, float]: ...
  34. @overload
  35. def get_offset(
  36. self,
  37. width: float,
  38. height: float,
  39. xdescent: float,
  40. ydescent: float,
  41. renderer: RendererBase
  42. ) -> tuple[float, float]: ...
  43. def set_width(self, width: float) -> None: ...
  44. def set_height(self, height: float) -> None: ...
  45. def get_visible_children(self) -> list[martist.Artist]: ...
  46. def get_children(self) -> list[martist.Artist]: ...
  47. def get_bbox(self, renderer: RendererBase) -> Bbox: ...
  48. def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ...
  49. class PackerBase(OffsetBox):
  50. height: float | None
  51. width: float | None
  52. sep: float | None
  53. pad: float | None
  54. mode: Literal["fixed", "expand", "equal"]
  55. align: Literal["top", "bottom", "left", "right", "center", "baseline"]
  56. def __init__(
  57. self,
  58. pad: float | None = ...,
  59. sep: float | None = ...,
  60. width: float | None = ...,
  61. height: float | None = ...,
  62. align: Literal["top", "bottom", "left", "right", "center", "baseline"] = ...,
  63. mode: Literal["fixed", "expand", "equal"] = ...,
  64. children: list[martist.Artist] | None = ...,
  65. ) -> None: ...
  66. class VPacker(PackerBase): ...
  67. class HPacker(PackerBase): ...
  68. class PaddedBox(OffsetBox):
  69. pad: float | None
  70. patch: FancyBboxPatch
  71. def __init__(
  72. self,
  73. child: martist.Artist,
  74. pad: float | None = ...,
  75. *,
  76. draw_frame: bool = ...,
  77. patch_attrs: dict[str, Any] | None = ...,
  78. ) -> None: ...
  79. def update_frame(self, bbox: Bbox, fontsize: float | None = ...) -> None: ...
  80. def draw_frame(self, renderer: RendererBase) -> None: ...
  81. class DrawingArea(OffsetBox):
  82. width: float
  83. height: float
  84. xdescent: float
  85. ydescent: float
  86. offset_transform: Transform
  87. dpi_transform: Transform
  88. def __init__(
  89. self,
  90. width: float,
  91. height: float,
  92. xdescent: float = ...,
  93. ydescent: float = ...,
  94. clip: bool = ...,
  95. ) -> None: ...
  96. @property
  97. def clip_children(self) -> bool: ...
  98. @clip_children.setter
  99. def clip_children(self, val: bool) -> None: ...
  100. def get_transform(self) -> Transform: ...
  101. # does not accept all options of superclass
  102. def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override]
  103. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  104. def add_artist(self, a: martist.Artist) -> None: ...
  105. class TextArea(OffsetBox):
  106. offset_transform: Transform
  107. def __init__(
  108. self,
  109. s: str,
  110. *,
  111. textprops: dict[str, Any] | None = ...,
  112. multilinebaseline: bool = ...,
  113. ) -> None: ...
  114. def set_text(self, s: str) -> None: ...
  115. def get_text(self) -> str: ...
  116. def set_multilinebaseline(self, t: bool) -> None: ...
  117. def get_multilinebaseline(self) -> bool: ...
  118. # does not accept all options of superclass
  119. def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override]
  120. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  121. class AuxTransformBox(OffsetBox):
  122. aux_transform: Transform
  123. offset_transform: Transform
  124. ref_offset_transform: Transform
  125. def __init__(self, aux_transform: Transform) -> None: ...
  126. def add_artist(self, a: martist.Artist) -> None: ...
  127. def get_transform(self) -> Transform: ...
  128. # does not accept all options of superclass
  129. def set_offset(self, xy: tuple[float, float]) -> None: ... # type: ignore[override]
  130. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  131. class AnchoredOffsetbox(OffsetBox):
  132. zorder: float
  133. codes: dict[str, int]
  134. loc: int
  135. borderpad: float
  136. pad: float
  137. prop: FontProperties
  138. patch: FancyBboxPatch
  139. def __init__(
  140. self,
  141. loc: str,
  142. *,
  143. pad: float = ...,
  144. borderpad: float = ...,
  145. child: OffsetBox | None = ...,
  146. prop: FontProperties | None = ...,
  147. frameon: bool = ...,
  148. bbox_to_anchor: BboxBase
  149. | tuple[float, float]
  150. | tuple[float, float, float, float]
  151. | None = ...,
  152. bbox_transform: Transform | None = ...,
  153. **kwargs
  154. ) -> None: ...
  155. def set_child(self, child: OffsetBox | None) -> None: ...
  156. def get_child(self) -> OffsetBox | None: ...
  157. def get_children(self) -> list[martist.Artist]: ...
  158. def get_bbox_to_anchor(self) -> Bbox: ...
  159. def set_bbox_to_anchor(
  160. self, bbox: BboxBase, transform: Transform | None = ...
  161. ) -> None: ...
  162. def update_frame(self, bbox: Bbox, fontsize: float | None = ...) -> None: ...
  163. class AnchoredText(AnchoredOffsetbox):
  164. txt: TextArea
  165. def __init__(
  166. self,
  167. s: str,
  168. loc: str,
  169. *,
  170. pad: float = ...,
  171. borderpad: float = ...,
  172. prop: dict[str, Any] | None = ...,
  173. **kwargs
  174. ) -> None: ...
  175. class OffsetImage(OffsetBox):
  176. image: BboxImage
  177. def __init__(
  178. self,
  179. arr: ArrayLike,
  180. *,
  181. zoom: float = ...,
  182. cmap: Colormap | str | None = ...,
  183. norm: Normalize | str | None = ...,
  184. interpolation: str | None = ...,
  185. origin: Literal["upper", "lower"] | None = ...,
  186. filternorm: bool = ...,
  187. filterrad: float = ...,
  188. resample: bool = ...,
  189. dpi_cor: bool = ...,
  190. **kwargs
  191. ) -> None: ...
  192. stale: bool
  193. def set_data(self, arr: ArrayLike | None) -> None: ...
  194. def get_data(self) -> ArrayLike | None: ...
  195. def set_zoom(self, zoom: float) -> None: ...
  196. def get_zoom(self) -> float: ...
  197. def get_children(self) -> list[martist.Artist]: ...
  198. def get_offset(self) -> tuple[float, float]: ... # type: ignore[override]
  199. class AnnotationBbox(martist.Artist, mtext._AnnotationBase):
  200. zorder: float
  201. offsetbox: OffsetBox
  202. arrowprops: dict[str, Any] | None
  203. xybox: tuple[float, float]
  204. boxcoords: CoordsType
  205. arrow_patch: FancyArrowPatch | None
  206. patch: FancyBboxPatch
  207. prop: FontProperties
  208. def __init__(
  209. self,
  210. offsetbox: OffsetBox,
  211. xy: tuple[float, float],
  212. xybox: tuple[float, float] | None = ...,
  213. xycoords: CoordsType = ...,
  214. boxcoords: CoordsType | None = ...,
  215. *,
  216. frameon: bool = ...,
  217. pad: float = ...,
  218. annotation_clip: bool | None = ...,
  219. box_alignment: tuple[float, float] = ...,
  220. bboxprops: dict[str, Any] | None = ...,
  221. arrowprops: dict[str, Any] | None = ...,
  222. fontsize: float | str | None = ...,
  223. **kwargs
  224. ) -> None: ...
  225. @property
  226. def xyann(self) -> tuple[float, float]: ...
  227. @xyann.setter
  228. def xyann(self, xyann: tuple[float, float]) -> None: ...
  229. @property
  230. def anncoords(
  231. self,
  232. ) -> CoordsType: ...
  233. @anncoords.setter
  234. def anncoords(
  235. self,
  236. coords: CoordsType,
  237. ) -> None: ...
  238. def get_children(self) -> list[martist.Artist]: ...
  239. def set_figure(self, fig: Figure | SubFigure) -> None: ...
  240. def set_fontsize(self, s: str | float | None = ...) -> None: ...
  241. def get_fontsize(self) -> float: ...
  242. def get_tightbbox(self, renderer: RendererBase | None = ...) -> Bbox: ...
  243. def update_positions(self, renderer: RendererBase) -> None: ...
  244. class DraggableBase:
  245. ref_artist: martist.Artist
  246. got_artist: bool
  247. mouse_x: int
  248. mouse_y: int
  249. background: Any
  250. @property
  251. def canvas(self) -> FigureCanvasBase: ...
  252. @property
  253. def cids(self) -> list[int]: ...
  254. def __init__(self, ref_artist: martist.Artist, use_blit: bool = ...) -> None: ...
  255. def on_motion(self, evt: Event) -> None: ...
  256. def on_pick(self, evt: Event) -> None: ...
  257. def on_release(self, event: Event) -> None: ...
  258. def disconnect(self) -> None: ...
  259. def save_offset(self) -> None: ...
  260. def update_offset(self, dx: float, dy: float) -> None: ...
  261. def finalize_offset(self) -> None: ...
  262. class DraggableOffsetBox(DraggableBase):
  263. offsetbox: OffsetBox
  264. def __init__(
  265. self, ref_artist: martist.Artist, offsetbox: OffsetBox, use_blit: bool = ...
  266. ) -> None: ...
  267. def save_offset(self) -> None: ...
  268. def update_offset(self, dx: float, dy: float) -> None: ...
  269. def get_loc_in_canvas(self) -> tuple[float, float]: ...
  270. class DraggableAnnotation(DraggableBase):
  271. annotation: mtext.Annotation
  272. def __init__(self, annotation: mtext.Annotation, use_blit: bool = ...) -> None: ...
  273. def save_offset(self) -> None: ...
  274. def update_offset(self, dx: float, dy: float) -> None: ...