Skip to content

Commit

Permalink
✨ Add transposed to auto_subplot
Browse files Browse the repository at this point in the history
  • Loading branch information
Kajiih committed Dec 17, 2024
1 parent 305ad33 commit a74e7c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/kajihs_utils/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = ["[email protected]"]
__repo_url__ = "https://github.com/Kajiih/kajihs_utils"
Expand Down
10 changes: 9 additions & 1 deletion src/kajihs_utils/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@


def auto_subplot(

Check warning on line 14 in src/kajihs_utils/pyplot.py

View workflow job for this annotation

GitHub Actions / build (3.12, ubuntu-latest)

Return type, "tuple[Unknown, Unknown]", is partially unknown (reportUnknownParameterType)
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.
Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit a74e7c8

Please sign in to comment.