Skip to content

eventplot breaks for default colors=None kwarg #3728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alimuldal opened this issue Oct 27, 2014 · 1 comment
Closed

eventplot breaks for default colors=None kwarg #3728

alimuldal opened this issue Oct 27, 2014 · 1 comment

Comments

@alimuldal
Copy link
Contributor

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.

@tacaswell tacaswell added this to the v1.4.3 milestone Oct 27, 2014
tacaswell added a commit that referenced this issue Oct 28, 2014
BUG : handling of color=None by eventplot(), fixes #3728
@tacaswell
Copy link
Member

Closed by #3729

tacaswell added a commit that referenced this issue Oct 28, 2014
BUG : handling of color=None by eventplot(), fixes #3728
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants