diff --git a/src/kajihs_utils/__about__.py b/src/kajihs_utils/__about__.py index 8541202..6fc4a4f 100644 --- a/src/kajihs_utils/__about__.py +++ b/src/kajihs_utils/__about__.py @@ -5,7 +5,7 @@ PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent __app_name__ = "kajihs_utils" -__version__ = "0.3.2" +__version__ = "0.3.3" __authors__ = ["Kajih"] __author_emails__ = ["itskajih@gmail.com"] __repo_url__ = "https://github.com/Kajiih/kajihs_utils" diff --git a/src/kajihs_utils/pyplot.py b/src/kajihs_utils/pyplot.py index 232f063..b1dc865 100644 --- a/src/kajihs_utils/pyplot.py +++ b/src/kajihs_utils/pyplot.py @@ -12,7 +12,12 @@ def auto_subplot( - size: int, /, ratio: float = 9 / 16, more_cols: bool = False, **subplot_params: Any + size: int, + /, + ratio: float = 9 / 16, + more_cols: bool = False, + transposed: bool = False, + **subplot_params: Any, ) -> tuple[Figure, ndarray[tuple[int], Any]]: """ Automatically creates a subplot grid with an adequate number of rows and columns. @@ -22,6 +27,7 @@ def auto_subplot( ratio: The threshold aspect ratio between rows and columns. more_cols: Whether there should be columns than rows instead of the opposite + transposed: Whether to transpose the indexes before flattening. **subplot_params: Additional keyword parameters for subplot. Returns: @@ -35,6 +41,8 @@ def auto_subplot( # if isinstance(axes, np.ndarray): # axes = axes.flatten() + if transposed: + axes = axes.T axes = axes.flatten() # Hide the remaining axes if there are more axes than subplots