text.pyi 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. from .artist import Artist
  2. from .backend_bases import RendererBase
  3. from .font_manager import FontProperties
  4. from .offsetbox import DraggableAnnotation
  5. from .path import Path
  6. from .patches import FancyArrowPatch, FancyBboxPatch
  7. from .textpath import ( # noqa: reexported API
  8. TextPath as TextPath,
  9. TextToPath as TextToPath,
  10. )
  11. from .transforms import (
  12. Bbox,
  13. BboxBase,
  14. Transform,
  15. )
  16. from collections.abc import Callable, Iterable
  17. from typing import Any, Literal
  18. from .typing import ColorType
  19. class Text(Artist):
  20. zorder: float
  21. def __init__(
  22. self,
  23. x: float = ...,
  24. y: float = ...,
  25. text: Any = ...,
  26. *,
  27. color: ColorType | None = ...,
  28. verticalalignment: Literal[
  29. "bottom", "baseline", "center", "center_baseline", "top"
  30. ] = ...,
  31. horizontalalignment: Literal["left", "center", "right"] = ...,
  32. multialignment: Literal["left", "center", "right"] | None = ...,
  33. fontproperties: str | Path | FontProperties | None = ...,
  34. rotation: float | Literal["vertical", "horizontal"] | None = ...,
  35. linespacing: float | None = ...,
  36. rotation_mode: Literal["default", "anchor"] | None = ...,
  37. usetex: bool | None = ...,
  38. wrap: bool = ...,
  39. transform_rotates_text: bool = ...,
  40. parse_math: bool | None = ...,
  41. antialiased: bool | None = ...,
  42. **kwargs
  43. ) -> None: ...
  44. def update(self, kwargs: dict[str, Any]) -> list[Any]: ...
  45. def get_rotation(self) -> float: ...
  46. def get_transform_rotates_text(self) -> bool: ...
  47. def set_rotation_mode(self, m: None | Literal["default", "anchor"]) -> None: ...
  48. def get_rotation_mode(self) -> Literal["default", "anchor"]: ...
  49. def set_bbox(self, rectprops: dict[str, Any]) -> None: ...
  50. def get_bbox_patch(self) -> None | FancyBboxPatch: ...
  51. def update_bbox_position_size(self, renderer: RendererBase) -> None: ...
  52. def get_wrap(self) -> bool: ...
  53. def set_wrap(self, wrap: bool) -> None: ...
  54. def get_color(self) -> ColorType: ...
  55. def get_fontproperties(self) -> FontProperties: ...
  56. def get_fontfamily(self) -> list[str]: ...
  57. def get_fontname(self) -> str: ...
  58. def get_fontstyle(self) -> Literal["normal", "italic", "oblique"]: ...
  59. def get_fontsize(self) -> float | str: ...
  60. def get_fontvariant(self) -> Literal["normal", "small-caps"]: ...
  61. def get_fontweight(self) -> int | str: ...
  62. def get_stretch(self) -> int | str: ...
  63. def get_horizontalalignment(self) -> Literal["left", "center", "right"]: ...
  64. def get_unitless_position(self) -> tuple[float, float]: ...
  65. def get_position(self) -> tuple[float, float]: ...
  66. def get_text(self) -> str: ...
  67. def get_verticalalignment(
  68. self,
  69. ) -> Literal["bottom", "baseline", "center", "center_baseline", "top"]: ...
  70. def get_window_extent(
  71. self, renderer: RendererBase | None = ..., dpi: float | None = ...
  72. ) -> Bbox: ...
  73. def set_backgroundcolor(self, color: ColorType) -> None: ...
  74. def set_color(self, color: ColorType) -> None: ...
  75. def set_horizontalalignment(
  76. self, align: Literal["left", "center", "right"]
  77. ) -> None: ...
  78. def set_multialignment(self, align: Literal["left", "center", "right"]) -> None: ...
  79. def set_linespacing(self, spacing: float) -> None: ...
  80. def set_fontfamily(self, fontname: str | Iterable[str]) -> None: ...
  81. def set_fontvariant(self, variant: Literal["normal", "small-caps"]) -> None: ...
  82. def set_fontstyle(
  83. self, fontstyle: Literal["normal", "italic", "oblique"]
  84. ) -> None: ...
  85. def set_fontsize(self, fontsize: float | str) -> None: ...
  86. def get_math_fontfamily(self) -> str: ...
  87. def set_math_fontfamily(self, fontfamily: str) -> None: ...
  88. def set_fontweight(self, weight: int | str) -> None: ...
  89. def set_fontstretch(self, stretch: int | str) -> None: ...
  90. def set_position(self, xy: tuple[float, float]) -> None: ...
  91. def set_x(self, x: float) -> None: ...
  92. def set_y(self, y: float) -> None: ...
  93. def set_rotation(self, s: float) -> None: ...
  94. def set_transform_rotates_text(self, t: bool) -> None: ...
  95. def set_verticalalignment(
  96. self, align: Literal["bottom", "baseline", "center", "center_baseline", "top"]
  97. ) -> None: ...
  98. def set_text(self, s: Any) -> None: ...
  99. def set_fontproperties(self, fp: FontProperties | str | Path | None) -> None: ...
  100. def set_usetex(self, usetex: bool | None) -> None: ...
  101. def get_usetex(self) -> bool: ...
  102. def set_parse_math(self, parse_math: bool) -> None: ...
  103. def get_parse_math(self) -> bool: ...
  104. def set_fontname(self, fontname: str | Iterable[str]) -> None: ...
  105. def get_antialiased(self) -> bool: ...
  106. def set_antialiased(self, antialiased: bool) -> None: ...
  107. class OffsetFrom:
  108. def __init__(
  109. self,
  110. artist: Artist | BboxBase | Transform,
  111. ref_coord: tuple[float, float],
  112. unit: Literal["points", "pixels"] = ...,
  113. ) -> None: ...
  114. def set_unit(self, unit: Literal["points", "pixels"]) -> None: ...
  115. def get_unit(self) -> Literal["points", "pixels"]: ...
  116. def __call__(self, renderer: RendererBase) -> Transform: ...
  117. class _AnnotationBase:
  118. xy: tuple[float, float]
  119. xycoords: str | tuple[str, str] | Artist | Transform | Callable[
  120. [RendererBase], Bbox | Transform
  121. ]
  122. def __init__(
  123. self,
  124. xy,
  125. xycoords: str
  126. | tuple[str, str]
  127. | Artist
  128. | Transform
  129. | Callable[[RendererBase], Bbox | Transform] = ...,
  130. annotation_clip: bool | None = ...,
  131. ) -> None: ...
  132. def set_annotation_clip(self, b: bool | None) -> None: ...
  133. def get_annotation_clip(self) -> bool | None: ...
  134. def draggable(
  135. self, state: bool | None = ..., use_blit: bool = ...
  136. ) -> DraggableAnnotation | None: ...
  137. class Annotation(Text, _AnnotationBase):
  138. arrowprops: dict[str, Any] | None
  139. arrow_patch: FancyArrowPatch | None
  140. def __init__(
  141. self,
  142. text: str,
  143. xy: tuple[float, float],
  144. xytext: tuple[float, float] | None = ...,
  145. xycoords: str
  146. | tuple[str, str]
  147. | Artist
  148. | Transform
  149. | Callable[[RendererBase], Bbox | Transform] = ...,
  150. textcoords: str
  151. | tuple[str, str]
  152. | Artist
  153. | Transform
  154. | Callable[[RendererBase], Bbox | Transform]
  155. | None = ...,
  156. arrowprops: dict[str, Any] | None = ...,
  157. annotation_clip: bool | None = ...,
  158. **kwargs
  159. ) -> None: ...
  160. @property
  161. def xycoords(
  162. self,
  163. ) -> str | tuple[str, str] | Artist | Transform | Callable[
  164. [RendererBase], Bbox | Transform
  165. ]: ...
  166. @xycoords.setter
  167. def xycoords(
  168. self,
  169. xycoords: str
  170. | tuple[str, str]
  171. | Artist
  172. | Transform
  173. | Callable[[RendererBase], Bbox | Transform],
  174. ) -> None: ...
  175. @property
  176. def xyann(self) -> tuple[float, float]: ...
  177. @xyann.setter
  178. def xyann(self, xytext: tuple[float, float]) -> None: ...
  179. def get_anncoords(
  180. self,
  181. ) -> str | tuple[str, str] | Artist | Transform | Callable[
  182. [RendererBase], Bbox | Transform
  183. ]: ...
  184. def set_anncoords(
  185. self,
  186. coords: str
  187. | tuple[str, str]
  188. | Artist
  189. | Transform
  190. | Callable[[RendererBase], Bbox | Transform],
  191. ) -> None: ...
  192. @property
  193. def anncoords(
  194. self,
  195. ) -> str | tuple[str, str] | Artist | Transform | Callable[
  196. [RendererBase], Bbox | Transform
  197. ]: ...
  198. @anncoords.setter
  199. def anncoords(
  200. self,
  201. coords: str
  202. | tuple[str, str]
  203. | Artist
  204. | Transform
  205. | Callable[[RendererBase], Bbox | Transform],
  206. ) -> None: ...
  207. def update_positions(self, renderer: RendererBase) -> None: ...
  208. # Drops `dpi` parameter from superclass
  209. def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox: ... # type: ignore[override]