legend.pyi 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. from matplotlib.axes import Axes
  2. from matplotlib.artist import Artist
  3. from matplotlib.backend_bases import MouseEvent
  4. from matplotlib.figure import Figure
  5. from matplotlib.font_manager import FontProperties
  6. from matplotlib.legend_handler import HandlerBase
  7. from matplotlib.lines import Line2D
  8. from matplotlib.offsetbox import (
  9. DraggableOffsetBox,
  10. )
  11. from matplotlib.patches import FancyBboxPatch, Patch, Rectangle
  12. from matplotlib.text import Text
  13. from matplotlib.transforms import (
  14. BboxBase,
  15. Transform,
  16. )
  17. import pathlib
  18. from collections.abc import Iterable
  19. from typing import Any, Literal, overload
  20. from .typing import ColorType
  21. class DraggableLegend(DraggableOffsetBox):
  22. legend: Legend
  23. def __init__(
  24. self, legend: Legend, use_blit: bool = ..., update: Literal["loc", "bbox"] = ...
  25. ) -> None: ...
  26. def finalize_offset(self) -> None: ...
  27. class Legend(Artist):
  28. codes: dict[str, int]
  29. zorder: float
  30. prop: FontProperties
  31. texts: list[Text]
  32. legend_handles: list[Artist | None]
  33. numpoints: int
  34. markerscale: float
  35. scatterpoints: int
  36. borderpad: float
  37. labelspacing: float
  38. handlelength: float
  39. handleheight: float
  40. handletextpad: float
  41. borderaxespad: float
  42. columnspacing: float
  43. shadow: bool
  44. isaxes: bool
  45. axes: Axes
  46. parent: Axes | Figure
  47. legendPatch: FancyBboxPatch
  48. def __init__(
  49. self,
  50. parent: Axes | Figure,
  51. handles: Iterable[Artist | tuple[Artist, ...]],
  52. labels: Iterable[str],
  53. *,
  54. loc: str | tuple[float, float] | int | None = ...,
  55. numpoints: int | None = ...,
  56. markerscale: float | None = ...,
  57. markerfirst: bool = ...,
  58. reverse: bool = ...,
  59. scatterpoints: int | None = ...,
  60. scatteryoffsets: Iterable[float] | None = ...,
  61. prop: FontProperties | dict[str, Any] | None = ...,
  62. fontsize: float | str | None = ...,
  63. labelcolor: ColorType
  64. | Iterable[ColorType]
  65. | Literal["linecolor", "markerfacecolor", "mfc", "markeredgecolor", "mec"]
  66. | None = ...,
  67. borderpad: float | None = ...,
  68. labelspacing: float | None = ...,
  69. handlelength: float | None = ...,
  70. handleheight: float | None = ...,
  71. handletextpad: float | None = ...,
  72. borderaxespad: float | None = ...,
  73. columnspacing: float | None = ...,
  74. ncols: int = ...,
  75. mode: Literal["expand"] | None = ...,
  76. fancybox: bool | None = ...,
  77. shadow: bool | dict[str, Any] | None = ...,
  78. title: str | None = ...,
  79. title_fontsize: float | None = ...,
  80. framealpha: float | None = ...,
  81. edgecolor: Literal["inherit"] | ColorType | None = ...,
  82. facecolor: Literal["inherit"] | ColorType | None = ...,
  83. bbox_to_anchor: BboxBase
  84. | tuple[float, float]
  85. | tuple[float, float, float, float]
  86. | None = ...,
  87. bbox_transform: Transform | None = ...,
  88. frameon: bool | None = ...,
  89. handler_map: dict[Artist | type, HandlerBase] | None = ...,
  90. title_fontproperties: FontProperties | dict[str, Any] | None = ...,
  91. alignment: Literal["center", "left", "right"] = ...,
  92. ncol: int = ...,
  93. draggable: bool = ...
  94. ) -> None: ...
  95. def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict[Any, Any]]: ...
  96. def set_ncols(self, ncols: int) -> None: ...
  97. @classmethod
  98. def get_default_handler_map(cls) -> dict[type, HandlerBase]: ...
  99. @classmethod
  100. def set_default_handler_map(cls, handler_map: dict[type, HandlerBase]) -> None: ...
  101. @classmethod
  102. def update_default_handler_map(
  103. cls, handler_map: dict[type, HandlerBase]
  104. ) -> None: ...
  105. def get_legend_handler_map(self) -> dict[type, HandlerBase]: ...
  106. @staticmethod
  107. def get_legend_handler(
  108. legend_handler_map: dict[type, HandlerBase], orig_handle: Any
  109. ) -> HandlerBase | None: ...
  110. def get_children(self) -> list[Artist]: ...
  111. def get_frame(self) -> Rectangle: ...
  112. def get_lines(self) -> list[Line2D]: ...
  113. def get_patches(self) -> list[Patch]: ...
  114. def get_texts(self) -> list[Text]: ...
  115. def set_alignment(self, alignment: Literal["center", "left", "right"]) -> None: ...
  116. def get_alignment(self) -> Literal["center", "left", "right"]: ...
  117. def set_loc(self, loc: str | tuple[float, float] | int | None = ...) -> None: ...
  118. def set_title(
  119. self, title: str, prop: FontProperties | str | pathlib.Path | None = ...
  120. ) -> None: ...
  121. def get_title(self) -> Text: ...
  122. def get_frame_on(self) -> bool: ...
  123. def set_frame_on(self, b: bool) -> None: ...
  124. draw_frame = set_frame_on
  125. def get_bbox_to_anchor(self) -> BboxBase: ...
  126. def set_bbox_to_anchor(
  127. self,
  128. bbox: BboxBase
  129. | tuple[float, float]
  130. | tuple[float, float, float, float]
  131. | None,
  132. transform: Transform | None = ...
  133. ) -> None: ...
  134. @overload
  135. def set_draggable(
  136. self,
  137. state: Literal[True],
  138. use_blit: bool = ...,
  139. update: Literal["loc", "bbox"] = ...,
  140. ) -> DraggableLegend: ...
  141. @overload
  142. def set_draggable(
  143. self,
  144. state: Literal[False],
  145. use_blit: bool = ...,
  146. update: Literal["loc", "bbox"] = ...,
  147. ) -> None: ...
  148. def get_draggable(self) -> bool: ...
  149. @property
  150. def legendHandles(self) -> list[Artist | None]: ...