Skip to content
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

EventCollection._is_horizontal remains uninitialized, causing eventplot error #6412

Closed
jniediek opened this issue May 12, 2016 · 3 comments

Comments

Projects
None yet
5 participants
@jniediek
Copy link

commented May 12, 2016

EventCollection does not set its property is_horizontal when the positions argument is empty. This causes an error in pyplot.eventplot if you pass multiple lists of events, with the first one empty. The reason is the line

if colls[0].is_horizontal():

in eventplot (defined in axes/_axes.py)

A minimal working example is the following:

import matplotlib.pyplot as mpl
mpl.eventplot([[0], [0, 1]])
mpl.show()
mpl.eventplot([[], [0, 1]])
mpl.show()

The first call to eventplot produces the correct plot, but the second one fails with

AttributeError: 'EventCollection' object has no attribute '_is_horizontal'

The error is present in matplotlib 1.5.1.

I would like to create a pull request to fix this. I suggest setting .is_horizontal to True by default.

@tacaswell tacaswell added this to the 1.5.2 (Critical bug fix release) milestone May 16, 2016

@tacaswell

This comment has been minimized.

Copy link
Member

commented May 16, 2016

It would be better to pick apart the horizontal/vertical state from the parsing the positions logic.

Can you also add a test for this?

@tacaswell tacaswell modified the milestones: 2.0.1 (next bug fix release), 1.5.2 (Critical bug fix release) May 16, 2016

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017

@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017

@jgosmann

This comment has been minimized.

Copy link

commented Feb 23, 2018

Any easy workaround until this is fixed?

@afvincent

This comment has been minimized.

Copy link
Contributor

commented Feb 23, 2018

:/ not sure. I'll try to open a PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.