Skip to content

Implemented issue #5856 #6172

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
wants to merge 6 commits into from
Closed
Changes from all commits
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
29 changes: 22 additions & 7 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2364,8 +2364,10 @@ def stem(self, *args, **kwargs):

Call signatures::

stem(y, linefmt='b-', markerfmt='bo', basefmt='r-')
stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-')
stem(y, linefmt='b-', markerfmt='bo', basefmt='r-',
orientation={'vertical'|'horizontal'})
stem(x, y, linefmt='b-', markerfmt='bo', basefmt='r-',
orientation={'vertical'|'horizontal'})

A stem plot plots vertical lines (using *linefmt*) at each *x*
location from the baseline to *y*, and places a marker there
Expand Down Expand Up @@ -2419,24 +2421,37 @@ def stem(self, *args, **kwargs):
basefmt = kwargs.pop('basefmt', args[2])
except IndexError:
basefmt = kwargs.pop('basefmt', 'r-')
try:
Copy link
Member

Choose a reason for hiding this comment

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

👎 on adding it as a possible positional.

orientation = kwargs.pop('orientation', args[3])
except IndexError:
orientation = kwargs.pop('orientation', 'vertical')

bottom = kwargs.pop('bottom', None)
label = kwargs.pop('label', None)

markerline, = self.plot(x, y, markerfmt, label="_nolegend_")
if (orientation == "vertical"):
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary parentheses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@QuLogic Hi I think it need both vertical and horizontal check there or else it will plot marker lines twice, unless you meant a else statement instead of elif like:
if (orientation == 'horizontal'):
...
else:
...

Copy link
Member

Choose a reason for hiding this comment

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

Parentheses, not condition:

if orientation == 'vertical':

markerline, = self.plot(x, y, markerfmt, label="_nolegend_")
elif (orientation == "horizontal"):
markerline, = self.plot(y, x, markerfmt, label="_nolegend_")

if bottom is None:
bottom = 0

stemlines = []
for thisx, thisy in zip(x, y):
l, = self.plot([thisx, thisx], [bottom, thisy], linefmt,
if (orientation == "vertical"):
l, = self.plot([thisx, thisx], [bottom, thisy], linefmt,
label="_nolegend_")
Copy link
Member

Choose a reason for hiding this comment

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

Unaligned with opening parenthesis.

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 this, do you mean "label=" has to be under [thisx,thisx... at line 2443?

Copy link
Member

Choose a reason for hiding this comment

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

Yes!

elif (orientation == "horizontal"):
l, = self.plot([bottom, thisy], [thisx, thisx], linefmt,
label="_nolegend_")
stemlines.append(l)

baseline, = self.plot([np.amin(x), np.amax(x)], [bottom, bottom],
if (orientation == "vertical"):
baseline, = self.plot([np.amin(x), np.amax(x)], [bottom, bottom],
basefmt, label="_nolegend_")
elif (orientation == "horizontal"):
baseline, = self.plot([bottom, bottom], [np.amin(x), np.amax(x)],
basefmt, label="_nolegend_")

self.hold(remember_hold)

stem_container = StemContainer((markerline, stemlines, baseline),
Expand Down