Skip to content

Commit 430ddc9

Browse files
0ctagonandrzejnovak
authored andcommitted
fix: correct kwargs handling in subplots
1 parent b108cc7 commit 430ddc9

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/mplhep/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
set_fitting_ylabel_fontsize,
7171
set_ylow,
7272
sort_legend,
73+
subplots,
7374
yscale_anchored_text,
7475
yscale_legend,
75-
subplots,
7676
)
7777

7878
# Configs

src/mplhep/utils.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,30 @@ def subplots(
566566
Array of Axes objects representing the subplots.
567567
"""
568568
if gridspec_kw is None and nrows > 1:
569-
gridspec_kw = {"height_ratios": [4*(1+0.25*(nrows-2)), *(1 for _ in range(nrows-1))]}
569+
gridspec_kw = {
570+
"height_ratios": [
571+
4 * (1 + 0.25 * (nrows - 2)),
572+
*(1 for _ in range(nrows - 1)),
573+
]
574+
}
570575
if figsize is None:
571-
figsize = (plt.rcParams["figure.figsize"][0], plt.rcParams["figure.figsize"][1] * (1 + 0.25 * (nrows - 1)))
576+
figsize = (
577+
plt.rcParams["figure.figsize"][0],
578+
plt.rcParams["figure.figsize"][1] * (1 + 0.25 * (nrows - 1)),
579+
)
572580

573-
fig, axes = plt.subplots(nrows=nrows, figsize=figsize, gridspec_kw=gridspec_kw)
581+
fig, axes = plt.subplots(
582+
nrows=nrows,
583+
figsize=figsize,
584+
gridspec_kw=gridspec_kw,
585+
*args, # NOQA: B026
586+
**kwargs, # type: ignore[call-overload]
587+
)
574588
if nrows > 1:
575589
fig.subplots_adjust(hspace=hspace)
576590

577591
for ax in axes[:-1]:
578592
_ = ax.xaxis.set_ticklabels([])
579593
ax.set_xlabel(" ")
580594

581-
return fig, axes
595+
return fig, axes

0 commit comments

Comments
 (0)