Permalink
Browse files

Initial work on WebAgg backend

  • Loading branch information...
1 parent 1c3836d commit dd325759d94800d4414d2d26e7a2d3fb669b08f2 @mdboom committed Oct 15, 2012
@@ -2,7 +2,8 @@
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
-ax = plt.subplot(111)
+fig = plt.figure()
+ax = fig.add_subplot(111)
plt.subplots_adjust(left=0.25, bottom=0.25)
t = np.arange(0.0, 1.0, 0.001)
a0 = 5
@@ -22,7 +23,7 @@ def update(val):
amp = samp.val
freq = sfreq.val
l.set_ydata(amp*np.sin(2*np.pi*freq*t))
- plt.draw()
+ fig.canvas.draw_idle()
sfreq.on_changed(update)
samp.on_changed(update)
@@ -37,8 +38,7 @@ def reset(event):
radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
def colorfunc(label):
l.set_color(label)
- plt.draw()
+ fig.canvas.draw_idle()
radio.on_clicked(colorfunc)
plt.show()
-
@@ -523,7 +523,7 @@ class Animation(object):
'''
def __init__(self, fig, event_source=None, blit=False):
self._fig = fig
- self._blit = blit
+ self._blit = blit and fig.canvas.supports_blit
# These are the basics of the animation. The frame sequence represents
# information for each frame of the animation and depends on how the
@@ -543,7 +543,7 @@ def __init__(self, fig, event_source=None, blit=False):
# fire events and try to draw to a deleted figure.
self._close_id = self._fig.canvas.mpl_connect('close_event',
self._stop)
- if blit:
+ if self._blit:
self._setup_blit()
def _start(self, *args):
View
@@ -2116,17 +2116,6 @@ def redraw_in_frame(self):
def get_renderer_cache(self):
return self._cachedRenderer
- def __draw_animate(self):
- # ignore for now; broken
- if self._lastRenderer is None:
- raise RuntimeError('You must first call ax.draw()')
- dsu = [(a.zorder, a) for a in self.animated.keys()]
- dsu.sort(key=lambda x: x[0])
- renderer = self._lastRenderer
- renderer.blit()
- for tmp, a in dsu:
- a.draw(renderer)
-
#### Axes rectangle characteristics
def get_frame_on(self):
@@ -1482,6 +1482,8 @@ class FigureCanvasBase(object):
'close_event'
]
+ supports_blit = True
+
def __init__(self, figure):
figure.set_canvas(self)
self.figure = figure
Oops, something went wrong.

0 comments on commit dd32575

Please sign in to comment.