X Tutup
Skip to content

Matplotlib 1.5 broken_barh fails on empty data. #5572

@mscuthbert

Description

@mscuthbert

A change from 1.4 to 1.5 has caused subplots to not be able to plot broken bars where the xrange has no data. Previously an empty list as xranges worked fine (no data was added to the subplot). Now it throws an IndexError exception:

  File "/home/travis/build/cuthbertLab/music21base/music21/graph.py", line 1058, in process
    ax.broken_barh(xranges, yrange, facecolors=faceColor, alpha=self.alpha)
  File "/home/travis/miniconda2/lib/python3.4/site-packages/matplotlib/__init__.py", line 1811, in inner
    return func(ax, *args, **kwargs)
  File "/home/travis/miniconda2/lib/python3.4/site-packages/matplotlib/axes/_axes.py", line 2336, in broken_barh
    self._process_unit_info(xdata=xranges[0],
  IndexError: list index out of range

This could be considered a backwards-incompatible issue. Or maybe a feature. In any case, it was something that my toolkit (music21) was counting on being able to use in some cases; a simple "if len(xranges) > 0:" wrap around the call fixed it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup