Skip to content

Backport PR #21127 on branch v3.5.x (Simplify argument parsing in stem().) #21159

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

Merged
Merged
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
48 changes: 8 additions & 40 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2881,50 +2881,18 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,

# defaults for formats
if linefmt is None:
try:
# fallback to positional argument
linefmt = args[0]
except IndexError:
linecolor = 'C0'
linemarker = 'None'
linestyle = '-'
else:
linestyle, linemarker, linecolor = \
_process_plot_format(linefmt)
else:
linestyle, linemarker, linecolor = _process_plot_format(linefmt)
linefmt = args[0] if len(args) > 0 else "C0-"
linestyle, linemarker, linecolor = _process_plot_format(linefmt)

if markerfmt is None:
try:
# fallback to positional argument
markerfmt = args[1]
except IndexError:
markercolor = 'C0'
markermarker = 'o'
markerstyle = 'None'
else:
markerstyle, markermarker, markercolor = \
_process_plot_format(markerfmt)
else:
markerstyle, markermarker, markercolor = \
_process_plot_format(markerfmt)
markerfmt = args[1] if len(args) > 1 else "C0o"
markerstyle, markermarker, markercolor = \
_process_plot_format(markerfmt)

if basefmt is None:
try:
# fallback to positional argument
basefmt = args[2]
except IndexError:
if rcParams['_internal.classic_mode']:
basecolor = 'C2'
else:
basecolor = 'C3'
basemarker = 'None'
basestyle = '-'
else:
basestyle, basemarker, basecolor = \
_process_plot_format(basefmt)
else:
basestyle, basemarker, basecolor = _process_plot_format(basefmt)
basefmt = (args[2] if len(args) > 2 else
"C2-" if rcParams["_internal.classic_mode"] else "C3-")
basestyle, basemarker, basecolor = _process_plot_format(basefmt)

# New behaviour in 3.1 is to use a LineCollection for the stemlines
if use_line_collection:
Expand Down