Skip to content

hist step UnboundLocalError #6448

Closed
Closed
@cdeil

Description

@cdeil

Trying to plot a histogram with histtype='step' results in an UnboundLocalError if the values are all outside the bins range:

>>> import matplotlib.pyplot as plt
>>> bins = [0, 1, 2, 3]
>>> values = [10, 11, 12]
>>> plt.hist(values, bins=bins, histtype='step')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/pyplot.py", line 2958, in hist
    stacked=stacked, data=data, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 1813, in inner
    return func(ax, *args, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 6209, in hist
    ymin = max(ymin*0.9, minimum) if not input_empty else minimum
UnboundLocalError: local variable 'ymin' referenced before assignment

I think @lzkelley said at #5221 (comment) that this can be considered an MPL bug, but that issue is closed, so I'm opening this new one.

This is with py35-numpy @1.11.0 and py35-matplotlib @1.5.1 on Python 3.5 with latest Macports and OS X.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions