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

Skip to content

Commit da8d510

Browse files
committed
Simplify creating style dict for errorbar bars/caps.
1 parent 0782c74 commit da8d510

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
@@ -3367,16 +3367,17 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33673367
if ecolor is None:
33683368
ecolor = base_style['color']
33693369

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

33813382
if elinewidth:
33823383
eb_lines_style['linewidth'] = elinewidth
@@ -3387,15 +3388,8 @@ def errorbar(self, x, y, yerr=None, xerr=None,
33873388
if key in kwargs:
33883389
eb_lines_style[key] = kwargs[key]
33893390

3390-
# Make the style dict for the caps, ejecting any marker information
3391-
# from format string.
3392-
eb_cap_style = dict(base_style)
3393-
eb_cap_style.pop('marker', None)
3394-
eb_cap_style.pop('markersize', None)
3395-
eb_cap_style.pop('markerfacecolor', None)
3396-
eb_cap_style.pop('markeredgewidth', None)
3397-
eb_cap_style.pop('markeredgecolor', None)
3398-
eb_cap_style['linestyle'] = 'none'
3391+
# Make the style dict for the caps.
3392+
eb_cap_style = {**base_style, 'linestyle': 'none'}
33993393
if capsize is None:
34003394
capsize = rcParams["errorbar.capsize"]
34013395
if capsize > 0:

0 commit comments

Comments
 (0)