Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace hardcoded parameter names when creating error bars #23376

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 4 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/behavior/23376-WLQ.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
All `kwargs` parameters to Line2D are now appropriately supported by axes.errorbar
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keys are now detected through the signature of Line2D, rather than through a
hardcoded list.
14 changes: 9 additions & 5 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import inspect
import itertools
import logging
import math
Expand Down Expand Up @@ -3451,14 +3452,17 @@ def _upcast_err(err):
if ecolor is None:
ecolor = base_style['color']

# Eject any line-specific information from format string, as it's not
# needed for bars or caps.
for key in ['marker', 'markersize', 'markerfacecolor',
# Eject anything that's not acceptable by LineCollection.set()
lc_keys = inspect.signature(mcoll.LineCollection.set).parameters
rej_keys = ['marker', 'markersize', 'markerfacecolor',
'markeredgewidth', 'markeredgecolor', 'markevery',
'linestyle', 'fillstyle', 'drawstyle', 'dash_capstyle',
'dash_joinstyle', 'solid_capstyle', 'solid_joinstyle',
'dashes']:
base_style.pop(key, None)
'dashes']
# Because we're resizing base_style
for key in tuple(base_style.keys()):
if key not in lc_keys or key in rej_keys:
base_style.pop(key, None)

# Make the style dict for the line collections (the bars).
eb_lines_style = {**base_style, 'color': ecolor}
Expand Down