Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 3, 2023
1 parent 269d545 commit 0c43a62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/mplhep/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import inspect
import warnings
from collections import OrderedDict, namedtuple
from typing import TYPE_CHECKING, Any, Union, List
from typing import TYPE_CHECKING, Any, List, Union

import matplotlib as mpl
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -299,7 +299,7 @@ def histplot(
else:
_labels = [str(lab) for lab in label]

_colors: List
_colors: list
if colors is None:
_colors = [None] * len(plottables)
elif isinstance(colors, str):
Expand Down Expand Up @@ -473,7 +473,11 @@ def iterable_not_string(arg):
if _colors[i] is not None:
_plot_info["color"] = _colors[i]
_f = ax.stairs(
**_plot_info, **plottables[i].to_stairs(), label=_labels[i], fill=True, **_kwargs
**_plot_info,
**plottables[i].to_stairs(),
label=_labels[i],
fill=True,
**_kwargs,
)
return_artists.append(StairsArtists(_f, None, None))
_artist = _f
Expand Down
22 changes: 19 additions & 3 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,27 @@ def test_histplot_inputs_pass(h, yerr, htype):
def test_color():
hs, bins = [[2, 3, 4], [5, 4, 3]], [0, 1, 2, 3]
fig, axs = plt.subplots(3, 2, figsize=(8, 12))
colors = ['green', 'blue']
colors = ["green", "blue"]
axs = axs.flatten()

for i, htype in enumerate(["step", "fill", "errorbar"]):
hep.histplot(hs[0], bins, yerr=True, histtype=htype, ax=axs[i * 2], alpha=0.7, color='red')
hep.histplot(hs, bins, yerr=True, histtype=htype, ax=axs[i * 2 + 1], alpha=0.7, color=colors)
hep.histplot(
hs[0],
bins,
yerr=True,
histtype=htype,
ax=axs[i * 2],
alpha=0.7,
color="red",
)
hep.histplot(
hs,
bins,
yerr=True,
histtype=htype,
ax=axs[i * 2 + 1],
alpha=0.7,
color=colors,
)

return fig

0 comments on commit 0c43a62

Please sign in to comment.