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

Skip to content

Commit 7ed17e3

Browse files
committed
Merge pull request #1426 from mdboom/browser_backend
WebAgg backend
2 parents 1c3836d + 1789f6c commit 7ed17e3

34 files changed

+1206
-37
lines changed

examples/widgets/slider_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import matplotlib.pyplot as plt
33
from matplotlib.widgets import Slider, Button, RadioButtons
44

5-
ax = plt.subplot(111)
5+
fig = plt.figure()
6+
ax = fig.add_subplot(111)
67
plt.subplots_adjust(left=0.25, bottom=0.25)
78
t = np.arange(0.0, 1.0, 0.001)
89
a0 = 5
@@ -22,7 +23,7 @@ def update(val):
2223
amp = samp.val
2324
freq = sfreq.val
2425
l.set_ydata(amp*np.sin(2*np.pi*freq*t))
25-
plt.draw()
26+
fig.canvas.draw_idle()
2627
sfreq.on_changed(update)
2728
samp.on_changed(update)
2829

@@ -37,8 +38,7 @@ def reset(event):
3738
radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
3839
def colorfunc(label):
3940
l.set_color(label)
40-
plt.draw()
41+
fig.canvas.draw_idle()
4142
radio.on_clicked(colorfunc)
4243

4344
plt.show()
44-

lib/matplotlib/animation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ class Animation(object):
523523
'''
524524
def __init__(self, fig, event_source=None, blit=False):
525525
self._fig = fig
526-
self._blit = blit
526+
# Disables blitting for backends that don't support it. This
527+
# allows users to request it if available, but still have a
528+
# fallback that works if it is not.
529+
self._blit = blit and fig.canvas.supports_blit
527530

528531
# These are the basics of the animation. The frame sequence represents
529532
# information for each frame of the animation and depends on how the
@@ -543,7 +546,7 @@ def __init__(self, fig, event_source=None, blit=False):
543546
# fire events and try to draw to a deleted figure.
544547
self._close_id = self._fig.canvas.mpl_connect('close_event',
545548
self._stop)
546-
if blit:
549+
if self._blit:
547550
self._setup_blit()
548551

549552
def _start(self, *args):

lib/matplotlib/axes.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,17 +2116,6 @@ def redraw_in_frame(self):
21162116
def get_renderer_cache(self):
21172117
return self._cachedRenderer
21182118

2119-
def __draw_animate(self):
2120-
# ignore for now; broken
2121-
if self._lastRenderer is None:
2122-
raise RuntimeError('You must first call ax.draw()')
2123-
dsu = [(a.zorder, a) for a in self.animated.keys()]
2124-
dsu.sort(key=lambda x: x[0])
2125-
renderer = self._lastRenderer
2126-
renderer.blit()
2127-
for tmp, a in dsu:
2128-
a.draw(renderer)
2129-
21302119
#### Axes rectangle characteristics
21312120

21322121
def get_frame_on(self):

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,8 @@ class FigureCanvasBase(object):
14821482
'close_event'
14831483
]
14841484

1485+
supports_blit = True
1486+
14851487
def __init__(self, figure):
14861488
figure.set_canvas(self)
14871489
self.figure = figure

0 commit comments

Comments
 (0)