diff --git a/doc/api/next_api_changes/behavior/23376-WLQ.rst b/doc/api/next_api_changes/behavior/23376-WLQ.rst new file mode 100644 index 000000000000..cf43fe800c71 --- /dev/null +++ b/doc/api/next_api_changes/behavior/23376-WLQ.rst @@ -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. diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0c80d87d7c22..6cd53553b92d 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1,4 +1,5 @@ import functools +import inspect import itertools import logging import math @@ -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}