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

Skip to content

Commit 32c3ece

Browse files
committed
Simplify creating style dict for errorbar bars/caps.
1 parent 66ddef1 commit 32c3ece

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,16 +3363,17 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33633363
if ecolor is None:
33643364
ecolor = base_style['color']
33653365

3366-
# Make the style dict for the line collections (the bars), ejecting any
3367-
# marker information from format string.
3368-
eb_lines_style = dict(base_style)
3369-
eb_lines_style.pop('marker', None)
3370-
eb_lines_style.pop('markersize', None)
3371-
eb_lines_style.pop('markerfacecolor', None)
3372-
eb_lines_style.pop('markeredgewidth', None)
3373-
eb_lines_style.pop('markeredgecolor', None)
3374-
eb_lines_style.pop('linestyle', None)
3375-
eb_lines_style['color'] = ecolor
3366+
# Eject any marker information from line format string, as it's not
3367+
# needed for bars or caps.
3368+
base_style.pop('marker', None)
3369+
base_style.pop('markersize', None)
3370+
base_style.pop('markerfacecolor', None)
3371+
base_style.pop('markeredgewidth', None)
3372+
base_style.pop('markeredgecolor', None)
3373+
base_style.pop('linestyle', None)
3374+
3375+
# Make the style dict for the line collections (the bars).
3376+
eb_lines_style = {**base_style, 'color': ecolor}
33763377

33773378
if elinewidth:
33783379
eb_lines_style['linewidth'] = elinewidth
@@ -3383,15 +3384,8 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33833384
if key in kwargs:
33843385
eb_lines_style[key] = kwargs[key]
33853386

3386-
# Make the style dict for the caps, ejecting any marker information
3387-
# from format string.
3388-
eb_cap_style = dict(base_style)
3389-
eb_cap_style.pop('marker', None)
3390-
eb_cap_style.pop('markersize', None)
3391-
eb_cap_style.pop('markerfacecolor', None)
3392-
eb_cap_style.pop('markeredgewidth', None)
3393-
eb_cap_style.pop('markeredgecolor', None)
3394-
eb_cap_style['linestyle'] = 'none'
3387+
# Make the style dict for the caps.
3388+
eb_cap_style = {**base_style, 'linestyle': 'none'}
33953389
if capsize is None:
33963390
capsize = rcParams["errorbar.capsize"]
33973391
if capsize > 0:

0 commit comments

Comments
 (0)