gridspec.pyi 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. from typing import Any, Literal, overload
  2. from numpy.typing import ArrayLike
  3. import numpy as np
  4. from matplotlib.axes import Axes, SubplotBase
  5. from matplotlib.backend_bases import RendererBase
  6. from matplotlib.figure import Figure, SubplotParams
  7. from matplotlib.transforms import Bbox
  8. class GridSpecBase:
  9. def __init__(
  10. self,
  11. nrows: int,
  12. ncols: int,
  13. height_ratios: ArrayLike | None = ...,
  14. width_ratios: ArrayLike | None = ...,
  15. ) -> None: ...
  16. @property
  17. def nrows(self) -> int: ...
  18. @property
  19. def ncols(self) -> int: ...
  20. def get_geometry(self) -> tuple[int, int]: ...
  21. def get_subplot_params(self, figure: Figure | None = ...) -> SubplotParams: ...
  22. def new_subplotspec(
  23. self, loc: tuple[int, int], rowspan: int = ..., colspan: int = ...
  24. ) -> SubplotSpec: ...
  25. def set_width_ratios(self, width_ratios: ArrayLike | None) -> None: ...
  26. def get_width_ratios(self) -> ArrayLike: ...
  27. def set_height_ratios(self, height_ratios: ArrayLike | None) -> None: ...
  28. def get_height_ratios(self) -> ArrayLike: ...
  29. def get_grid_positions(
  30. self, fig: Figure, raw: bool = ...
  31. ) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: ...
  32. @staticmethod
  33. def _check_gridspec_exists(figure: Figure, nrows: int, ncols: int) -> GridSpec: ...
  34. def __getitem__(
  35. self, key: tuple[int | slice, int | slice] | slice | int
  36. ) -> SubplotSpec: ...
  37. @overload
  38. def subplots(
  39. self,
  40. *,
  41. sharex: bool | Literal["all", "row", "col", "none"] = ...,
  42. sharey: bool | Literal["all", "row", "col", "none"] = ...,
  43. squeeze: Literal[False],
  44. subplot_kw: dict[str, Any] | None = ...
  45. ) -> np.ndarray: ...
  46. @overload
  47. def subplots(
  48. self,
  49. *,
  50. sharex: bool | Literal["all", "row", "col", "none"] = ...,
  51. sharey: bool | Literal["all", "row", "col", "none"] = ...,
  52. squeeze: Literal[True] = ...,
  53. subplot_kw: dict[str, Any] | None = ...
  54. ) -> np.ndarray | SubplotBase | Axes: ...
  55. class GridSpec(GridSpecBase):
  56. left: float | None
  57. bottom: float | None
  58. right: float | None
  59. top: float | None
  60. wspace: float | None
  61. hspace: float | None
  62. figure: Figure | None
  63. def __init__(
  64. self,
  65. nrows: int,
  66. ncols: int,
  67. figure: Figure | None = ...,
  68. left: float | None = ...,
  69. bottom: float | None = ...,
  70. right: float | None = ...,
  71. top: float | None = ...,
  72. wspace: float | None = ...,
  73. hspace: float | None = ...,
  74. width_ratios: ArrayLike | None = ...,
  75. height_ratios: ArrayLike | None = ...,
  76. ) -> None: ...
  77. def update(self, **kwargs: float | None) -> None: ...
  78. def locally_modified_subplot_params(self) -> list[str]: ...
  79. def tight_layout(
  80. self,
  81. figure: Figure,
  82. renderer: RendererBase | None = ...,
  83. pad: float = ...,
  84. h_pad: float | None = ...,
  85. w_pad: float | None = ...,
  86. rect: tuple[float, float, float, float] | None = ...,
  87. ) -> None: ...
  88. class GridSpecFromSubplotSpec(GridSpecBase):
  89. figure: Figure | None
  90. def __init__(
  91. self,
  92. nrows: int,
  93. ncols: int,
  94. subplot_spec: SubplotSpec,
  95. wspace: float | None = ...,
  96. hspace: float | None = ...,
  97. height_ratios: ArrayLike | None = ...,
  98. width_ratios: ArrayLike | None = ...,
  99. ) -> None: ...
  100. def get_topmost_subplotspec(self) -> SubplotSpec: ...
  101. class SubplotSpec:
  102. num1: int
  103. def __init__(
  104. self, gridspec: GridSpecBase, num1: int, num2: int | None = ...
  105. ) -> None: ...
  106. @staticmethod
  107. def _from_subplot_args(figure, args): ...
  108. @property
  109. def num2(self) -> int: ...
  110. @num2.setter
  111. def num2(self, value: int) -> None: ...
  112. def get_gridspec(self) -> GridSpec: ...
  113. def get_geometry(self) -> tuple[int, int, int, int]: ...
  114. @property
  115. def rowspan(self) -> range: ...
  116. @property
  117. def colspan(self) -> range: ...
  118. def is_first_row(self) -> bool: ...
  119. def is_last_row(self) -> bool: ...
  120. def is_first_col(self) -> bool: ...
  121. def is_last_col(self) -> bool: ...
  122. def get_position(self, figure: Figure) -> Bbox: ...
  123. def get_topmost_subplotspec(self) -> SubplotSpec: ...
  124. def __eq__(self, other: object) -> bool: ...
  125. def __hash__(self) -> int: ...
  126. def subgridspec(
  127. self, nrows: int, ncols: int, **kwargs
  128. ) -> GridSpecFromSubplotSpec: ...