Skip to content

Commit

Permalink
fix: if available, yerr is shown by default for step histtype
Browse files Browse the repository at this point in the history
  • Loading branch information
0ctagon committed Oct 24, 2024
1 parent 2301c7d commit 58a9b1b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/mplhep/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ def iterable_not_string(arg):

if "step" in histtype:
for i in range(len(plottables)):
if isinstance(yerr, bool) and yerr and plottables[i].variances is not None:
do_errors = True
else:
do_errors = yerr is not False and (yerr is not None or w2 is not None)
do_errors = yerr is not False and (
(yerr is not None or w2 is not None)
or (plottables[i].variances is not None)
)

_kwargs = _chunked_kwargs[i]

Expand Down
20 changes: 10 additions & 10 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_onebin_hist():
fig, axs = plt.subplots()
h = hist.Hist(hist.axis.Regular(1, 0, 1))
h.fill([-1, 0.5])
hep.histplot(h, yerr=True, ax=axs)
hep.histplot(h, ax=axs)
return fig


Expand Down Expand Up @@ -138,10 +138,10 @@ def test_histplot_flow():
fig, axs = plt.subplots(2, 2, sharey=True, figsize=(10, 10))
axs = axs.flatten()

hep.histplot(h, ax=axs[0], yerr=True, flow="hint")
hep.histplot(h, ax=axs[1], yerr=True, flow="show")
hep.histplot(h, ax=axs[2], yerr=True, flow="sum")
hep.histplot(h, ax=axs[3], yerr=True, flow=None)
hep.histplot(h, ax=axs[0], flow="hint")
hep.histplot(h, ax=axs[1], flow="show")
hep.histplot(h, ax=axs[2], flow="sum")
hep.histplot(h, ax=axs[3], flow=None)

axs[0].set_title("Default(hint)", fontsize=18)
axs[1].set_title("Show", fontsize=18)
Expand Down Expand Up @@ -213,10 +213,10 @@ def test_histplot_uproot_flow():
fig, axs = plt.subplots(2, 2, sharey=True, figsize=(10, 10))
axs = axs.flatten()

hep.histplot(h, ax=axs[0], yerr=True, flow="show")
hep.histplot(h2, ax=axs[1], yerr=True, flow="show")
hep.histplot(h3, ax=axs[2], yerr=True, flow="show")
hep.histplot(h4, ax=axs[3], yerr=True, flow="show")
hep.histplot(h, ax=axs[0], flow="show")
hep.histplot(h2, ax=axs[1], flow="show")
hep.histplot(h3, ax=axs[2], flow="show")
hep.histplot(h4, ax=axs[3], flow="show")

axs[0].set_title("Two-side overflow", fontsize=18)
axs[1].set_title("Left-side overflow", fontsize=18)
Expand Down Expand Up @@ -648,7 +648,7 @@ def test_histplot_bar():

axs[1].set_title("Histtype barstep", fontsize=18)
hep.histplot(
[h1, h2, h3], bins, histtype="barstep", label=["h1", "h2", "h3"], ax=axs[1]
[h1, h2, h3], bins, histtype="barstep", yerr=False, label=["h1", "h2", "h3"], ax=axs[1]
)
axs[1].legend()

Expand Down

0 comments on commit 58a9b1b

Please sign in to comment.