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

Skip to content

Commit 1abd966

Browse files
committed
Don't modify dictionary input to widgets
1 parent cd8420a commit 1abd966

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/matplotlib/widgets.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,9 +2728,11 @@ def __init__(self, ax, positions, direction, line_props=None,
27282728
_api.check_in_list(['horizontal', 'vertical'], direction=direction)
27292729
self._direction = direction
27302730

2731-
if line_props is None:
2732-
line_props = {}
2733-
line_props.update({'visible': False, 'animated': useblit})
2731+
line_props = {
2732+
**(line_props if line_props is not None else {}),
2733+
'visible': False,
2734+
'animated': useblit,
2735+
}
27342736

27352737
line_fun = ax.axvline if self.direction == 'horizontal' else ax.axhline
27362738

@@ -3034,9 +3036,8 @@ def __init__(self, ax, onselect, drawtype='box',
30343036
if props is None:
30353037
props = dict(facecolor='red', edgecolor='black',
30363038
alpha=0.2, fill=True)
3037-
props['animated'] = self.useblit
3038-
self._visible = props.pop('visible', self._visible)
3039-
self._props = props
3039+
self._props = {**props, 'animated': self.useblit}
3040+
self._visible = self._props.pop('visible', self._visible)
30403041
to_draw = self._init_shape(**self._props)
30413042
self.ax.add_patch(to_draw)
30423043
if drawtype == 'line':
@@ -3047,8 +3048,7 @@ def __init__(self, ax, onselect, drawtype='box',
30473048
if lineprops is None:
30483049
lineprops = dict(color='black', linestyle='-',
30493050
linewidth=2, alpha=0.5)
3050-
lineprops['animated'] = self.useblit
3051-
self._props = lineprops
3051+
self._props = {**lineprops, 'animated': self.useblit}
30523052
to_draw = Line2D([0, 0], [0, 0], visible=False, **self._props)
30533053
self.ax.add_line(to_draw)
30543054

@@ -3621,10 +3621,12 @@ def __init__(self, ax, onselect=None, useblit=True, props=None,
36213621
button=None):
36223622
super().__init__(ax, onselect, useblit=useblit, button=button)
36233623
self.verts = None
3624-
if props is None:
3625-
props = dict()
3626-
# self.useblit may be != useblit, if the canvas doesn't support blit.
3627-
props.update(animated=self.useblit, visible=False)
3624+
props = {
3625+
**(props if props is not None else {}),
3626+
# Note that self.useblit may be != useblit, if the canvas doesn't
3627+
# support blitting.
3628+
'animated': self.useblit, 'visible': False,
3629+
}
36283630
line = Line2D([], [], **props)
36293631
self.ax.add_line(line)
36303632
self._selection_artist = line
@@ -3759,8 +3761,7 @@ def __init__(self, ax, onselect, useblit=False,
37593761

37603762
if props is None:
37613763
props = dict(color='k', linestyle='-', linewidth=2, alpha=0.5)
3762-
props['animated'] = self.useblit
3763-
self._props = props
3764+
self._props = {**props, 'animated': self.useblit}
37643765
self._selection_artist = line = Line2D([], [], **self._props)
37653766
self.ax.add_line(line)
37663767

0 commit comments

Comments
 (0)