Skip to content

Fix stem(use_line_collection) - #13745

Merged
QuLogic merged 1 commit into
matplotlib:masterfrom
timhoffm:fix-stem-linestyle
Mar 24, 2019
Merged

QuLogic merged 1 commit into
matplotlib:masterfrom
timhoffm:fix-stem-linestyle

Conversation

@timhoffm

Copy link
Copy Markdown
Member

PR Summary

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0.1, 2 * np.pi, 41)
y = np.exp(np.sin(x))

markerline, stemlines, baseline = plt.stem(x, y, linefmt='grey',
                                           use_line_collection=True)

fails because linefmt is resolved to linestyle = None, which is not a valid parameter value for LineCollection.

The fix is consistent with the behavior of use_line_collection=False.

@timhoffm timhoffm mentioned this pull request Mar 23, 2019
@timhoffm timhoffm added this to the v3.1.0 milestone Mar 23, 2019
@timhoffm timhoffm added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Mar 23, 2019
@timhoffm

Copy link
Copy Markdown
Member Author

Marking as release critical, because use_line_collection is the recommended way of operation in 3.1, and that should not be broken.

@jklymak

jklymak commented Mar 23, 2019

Copy link
Copy Markdown
Member

Do we know how this broke?

@timhoffm

Copy link
Copy Markdown
Member Author

I think this was an oversight in the original implementation and never worked with use_line_collection.

@jklymak

jklymak commented Mar 23, 2019

Copy link
Copy Markdown
Member

I suppose it could use a test in that case 😉

@timhoffm
timhoffm force-pushed the fix-stem-linestyle branch from 8bf4e02 to 9381302 Compare March 23, 2019 16:37
@timhoffm

Copy link
Copy Markdown
Member Author

Test added.

Comment thread lib/matplotlib/axes/_axes.py Outdated
stemlines = []
stemlines = [((xi, bottom), (xi, yi)) for xi, yi in zip(x, y)]
if linestyle is None:
linestyle = 'solid'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this maybe rather evaluate the lines.linestyle rc parameter?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. Thanks!

@timhoffm
timhoffm force-pushed the fix-stem-linestyle branch from 9381302 to 013dfc1 Compare March 24, 2019 00:44
@timhoffm timhoffm mentioned this pull request Mar 24, 2019
6 tasks
@QuLogic
QuLogic merged commit bdfeaec into matplotlib:master Mar 24, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 24, 2019
@timhoffm
timhoffm deleted the fix-stem-linestyle branch March 24, 2019 09:02
timhoffm added a commit that referenced this pull request Mar 24, 2019
…745-on-v3.1.x

Backport PR #13745 on branch v3.1.x (Fix stem(use_line_collection))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants