8000 FIX: eventplot 'colors' kwarg (#8193) by afvincent · Pull Request #8204 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: eventplot 'colors' kwarg (#8193) #8204

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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix the phrasing of some sentences.
  • Loading branch information
afvincent committed Mar 22, 2017
commit c0c6bc91a1acdaf40a452b831ddcb6e44c7d3261
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
For *linelengths*, *linewidths*, *colors*, and *linestyles*, if only
a single value is given, that value is applied to all lines. If an
array-like is given, it must have the same length as *positions*, and
each row of the array will be applied to the corresponding row or
column of events.
each value will be applied to the corresponding row of the array.

Example
-------
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,8 @@ def __init__(self,
if positions is None or len(positions) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would just write positions = np.asarray(positions) (or np.atleast_1d(positions) if we want to support scalars)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and then you know for sure it has an ndim attribute)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring does not say that one should expect scalars to be supported, and the other collections classes does not seem to support it either. So I would say => np.asarray.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now using positions = np.asarray(positions) since fc212ee.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted on a @tacaswell's comment.

segments = []
elif hasattr(positions, 'ndim') and positions.ndim > 1:
raise ValueError('positions cannot have a dimensionality greater '
'than 1 (in the ndarray sense)')
raise ValueError('positions cannot be an array with more than '
'one dimension.')
elif (orientation is None or orientation.lower() == 'none' or
orientation.lower() == 'horizontal'):
positions.sort()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to sort the positions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not totally understand how it works, be it looks like it is needed by how the “offsets” are handled in LineCollection. In particular, the _add_offsets seems to be sensitive to the ordering of the segments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the fun I tried to not sorting the positions: the tests do not pass anymore. So I would be inclined to conclude that indeed we need to sort the positions ^^…

Expand Down
0