8000 Fix `text.set(bbox=None)`. · matplotlib/matplotlib@2ee109d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ee109d

Browse files
committed
Fix text.set(bbox=None).
So far, in from pylab import * t = plt.text(.5, .5, "foo") t.set(bbox=dict(facecolor='red', alpha=0.5)) # Other stuff, e.g. animation. t.set(bbox=None) plt.show() The line `t.set(bbox=None)` has no effect and leaves the previous bbox (even though `t.set_bbox(None)` would correctly remove it). Fix by not dropping the `{"bbox": None}` 8000 entry from the kwargs.
1 parent 80a5e99 commit 2ee109d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/text.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ def update(self, kwargs):
239239
"""
240240
Update properties from a dictionary.
241241
"""
242-
bbox = kwargs.pop('bbox', None)
242+
# Update bbox last, as it depends on font properties.
243+
sentinel = object() # bbox can be None, so use another sentinel.
244+
bbox = kwargs.pop("bbox", sentinel)
243245
super(Text, self).update(kwargs)
244-
if bbox:
245-
self.set_bbox(bbox) # depends on font properties
246+
if bbox is not sentinel:
247+
self.set_bbox(bbox)
246248

247249
def __getstate__(self):
248250
d = super(Text, self).__getstate__()

0 commit comments

Comments
 (0)
0