Skip to content

Commit 5d1cd3c

Browse files
committed
Merge branch 'v2.x'
2 parents adfeab7 + 08eccfb commit 5d1cd3c

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

doc/api/api_changes.rst

+9
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ where "ax" is an ``Axes3d`` object created with something like ::
155155
ax = plt.sublot(111, projection='3d')
156156

157157

158+
Stale figure behavior
159+
---------------------
160+
161+
Attempting to draw the figure will now mark it as not stale (independent if
162+
the draw succeeds). This change is to prevent repeatedly trying to re-draw a
163+
figure which is raising an error on draw. The previous behavior would only mark
164+
a figure as not stale after a full re-draw succeeded.
165+
166+
158167
Changes in 1.5.3
159168
================
160169

lib/matplotlib/figure.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -1216,19 +1216,6 @@ def draw(self, renderer):
12161216
if not self.get_visible():
12171217
return
12181218

1219-
renderer.open_group('figure')
1220-
# prevent triggering call backs during the draw process
1221-
self._stale = True
1222-
if self.get_tight_layout() and self.axes:
1223-
try:
1224-
self.tight_layout(renderer, **self._tight_parameters)
1225-
except ValueError:
1226-
pass
1227-
# ValueError can occur when resizing a window.
1228-
1229-
if self.frameon:
1230-
self.patch.draw(renderer)
1231-
12321219
# a list of (zorder, func_to_call, list_of_args)
12331220
dsu = []
12341221

@@ -1258,11 +1245,24 @@ def draw(self, renderer):
12581245
dsu = [row for row in dsu if not row[1].get_animated()]
12591246
dsu.sort(key=itemgetter(0))
12601247

1261-
mimage._draw_list_compositing_images(
1262-
renderer, self, dsu, self.suppressComposite)
1248+
try:
1249+
renderer.open_group('figure')
1250+
if self.get_tight_layout() and self.axes:
1251+
try:
1252+
self.tight_layout(renderer, **self._tight_parameters)
1253+
except ValueError:
1254+
pass
1255+
# ValueError can occur when resizing a window.
1256+
1257+
if self.frameon:
1258+
self.patch.draw(renderer)
1259+
1260+
mimage._draw_list_compositing_images(
1261+
renderer, self, dsu, self.suppressComposite)
12631262

1264-
renderer.close_group('figure')
1265-
self.stale = False
1263+
renderer.close_group('figure')
1264+
finally:
1265+
self.stale = False
12661266

12671267
self._cachedRenderer = renderer
12681268
self.canvas.draw_event(renderer)

lib/matplotlib/patches.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def set_alpha(self, alpha):
356356
except TypeError:
357357
raise TypeError('alpha must be a float or None')
358358
artist.Artist.set_alpha(self, alpha)
359-
self._set_facecolor(self._facecolor)
359+
self._set_facecolor(self._original_facecolor)
360360
self._set_edgecolor(self._original_edgecolor)
361361
# stale is already True
362362

lib/matplotlib/tests/test_patches.py

+8
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ def test_patch_alpha_override():
176176
ax.set_ylim([-1, 2])
177177

178178

179+
@cleanup(style='default')
180+
def test_patch_color_none():
181+
# Make sure the alpha kwarg does not override 'none' facecolor.
182+
# Addresses issue #7478.
183+
c = plt.Circle((0, 0), 1, facecolor='none', alpha=1)
184+
assert c.get_facecolor()[0] == 0
185+
186+
179187
@image_comparison(baseline_images=['patch_custom_linestyle'],
180188
remove_text=True)
181189
def test_patch_custom_linestyle():

0 commit comments

Comments
 (0)