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

Skip to content

Commit 07f34aa

Browse files
committed
Avoid modifying user input to Axes.bar
The `error_kw` parameter is a dictionary, on which `setdefault` and `pop` are called, which would modify user input.
1 parent 787f308 commit 07f34aa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,8 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
24342434
# checking and processing will be left to the errorbar method.
24352435
xerr = kwargs.pop('xerr', None)
24362436
yerr = kwargs.pop('yerr', None)
2437-
error_kw = kwargs.pop('error_kw', {})
2437+
error_kw = kwargs.pop('error_kw', None)
2438+
error_kw = {} if error_kw is None else error_kw.copy()
24382439
ezorder = error_kw.pop('zorder', None)
24392440
if ezorder is None:
24402441
ezorder = kwargs.get('zorder', None)
@@ -2590,9 +2591,8 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
25902591

25912592
error_kw.setdefault("label", '_nolegend_')
25922593

2593-
errorbar = self.errorbar(ex, ey,
2594-
yerr=yerr, xerr=xerr,
2595-
fmt='none', **error_kw)
2594+
errorbar = self.errorbar(ex, ey, yerr=yerr, xerr=xerr, fmt='none',
2595+
**error_kw)
25962596
else:
25972597
errorbar = None
25982598

0 commit comments

Comments
 (0)