Skip to content

Commit

Permalink
Add sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejnovak committed Feb 21, 2020
1 parent 580a7df commit 96aa234
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions coffea/hist/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def normal_interval(pw, tw, pw2, tw2, coverage=_coverage1sd):

def plot1d(hist, ax=None, clear=True, overlay=None, stack=False, overflow='none', line_opts=None,
fill_opts=None, error_opts=None, legend_opts={}, overlay_overflow='none',
density=False, binwnorm=None, densitymode='unit'):
density=False, binwnorm=None, densitymode='unit', order=None):
"""Create a 1D plot from a 1D or 2D `Hist` object
Parameters
Expand All @@ -129,6 +129,8 @@ def plot1d(hist, ax=None, clear=True, overlay=None, stack=False, overflow='none'
In the case that ``hist`` is 2D, specify the axis of hist to overlay (remaining axis will be x axis)
stack : bool, optional
Whether to stack or overlay non-axis dimension (if it exists)
order : list, optional
How to order when stacking. Take a list of identifiers.
overflow : str, optional
If overflow behavior is not 'none', extra bins will be drawn on either end of the nominal
axis range, to represent the contents of the overflow bins. See `Hist.sum` documentation
Expand Down Expand Up @@ -207,7 +209,10 @@ def plot1d(hist, ax=None, clear=True, overlay=None, stack=False, overflow='none'
ax.set_xlabel(axis.label)
ax.set_ylabel(hist.label)
edges = axis.edges(overflow=overflow)
identifiers = hist.identifiers(overlay, overflow=overlay_overflow) if overlay is not None else [None]
if order is None:
identifiers = hist.identifiers(overlay, overflow=overlay_overflow) if overlay is not None else [None]
else:
identifiers = order
plot_info = {
'identifier': identifiers,
'label': list(map(str, identifiers)),
Expand Down

0 comments on commit 96aa234

Please sign in to comment.