Skip to content

Commit

Permalink
fix: legend linestyle for step histogram (#496)
Browse files Browse the repository at this point in the history
* forward linestyle to _e_leg and remove xerr

* fix exception if no linestyle is given

* update test
  • Loading branch information
8me authored Apr 30, 2024
1 parent 57d95c8 commit f6c9542
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/mplhep/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,15 @@ def iterable_not_string(arg):

if do_errors:
_kwargs = soft_update_kwargs(_kwargs, {"color": _s.get_edgecolor()})
_ls = _kwargs.pop("linestyle", "-")
_kwargs["linestyle"] = "none"
_plot_info = plottables[i].to_errorbar()
_e = ax.errorbar(
**_plot_info,
**_kwargs,
)
_e_leg = ax.errorbar(
[], [], yerr=1, xerr=1, color=_s.get_edgecolor(), label=_label
[], [], yerr=1, xerr=None, color=_s.get_edgecolor(), label=_label, linestyle=_ls
)
return_artists.append(
StairsArtists(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def test_simple(mock_matplotlib):
approx([]),
approx([]),
yerr=1,
xerr=1,
xerr=None,
linestyle='-',
color=ax.stairs().get_edgecolor(),
label="X",
)
Expand Down

0 comments on commit f6c9542

Please sign in to comment.