Closed
Description
To reproduce the bug:
In [1]: events = np.random.exponential(0.5, size=100)
In [2]: plt.eventplot(events)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-51aef4c82a54> in <module>()
----> 1 plt.eventplot(events)
/usr/lib/pymodules/python2.7/matplotlib/pyplot.pyc in eventplot(positions, orientation, lineoffsets, linelengths, linewidths, colors, linestyles, hold, **kwargs)
2718 lineoffsets=lineoffsets, linelengths=linelengths,
2719 linewidths=linewidths, colors=colors,
-> 2720 linestyles=linestyles, **kwargs)
2721 draw_if_interactive()
2722 finally:
/usr/lib/pymodules/python2.7/matplotlib/axes.pyc in eventplot(self, positions, orientation, lineoffsets, linelengths, linewidths, colors, linestyles, **kwargs)
3981 linewidth=linewidth,
3982 color=color,
-> 3983 linestyle=linestyle)
3984 self.add_collection(coll)
3985 coll.update(kwargs)
/usr/lib/pymodules/python2.7/matplotlib/collections.pyc in __init__(self, positions, orientation, lineoffset, linelength, linewidth, color, linestyle, antialiased, **kwargs)
1181 antialiaseds=antialiased,
1182 linestyles=linestyle,
-> 1183 **kwargs)
1184
1185 self._linelength = linelength
/usr/lib/pymodules/python2.7/matplotlib/collections.pyc in __init__(self, segments, linewidths, colors, antialiaseds, linestyles, offsets, transOffset, norm, cmap, pickradius, zorder, **kwargs)
997 self.set_linestyles(linestyles)
998
--> 999 colors = mcolors.colorConverter.to_rgba_array(colors)
1000
1001 Collection.__init__(
/usr/lib/pymodules/python2.7/matplotlib/colors.pyc in to_rgba_array(self, c, alpha)
390 if isinstance(c, np.ndarray):
391 if c.ndim != 2 and c.dtype.kind not in 'SU':
--> 392 raise ValueError("Color array must be two-dimensional")
393 if (c.ndim == 2 and c.shape[1] == 4 and c.dtype.kind == 'f'):
394 if (c.ravel() > 1).any() or (c.ravel() < 0).any():
ValueError: Color array must be two-dimensional
It seems that what's happening is that mcoll.EventCollection()
receives color=array([None], dtype=object)
and tries to interpret this as a sequence of color values rather than a single value.