There was an error while loading. Please reload this page.
1 parent 9e20541 commit 65497d3Copy full SHA for 65497d3
1 file changed
examples/user_interfaces/embedding_in_qt_sgskip.py
@@ -45,19 +45,18 @@ def __init__(self):
45
self._static_ax.plot(t, np.tan(t), ".")
46
47
self._dynamic_ax = dynamic_canvas.figure.subplots()
48
+ t = np.linspace(0, 10, 101)
49
+ # Set up a Line2D.
50
+ self._line, = self._dynamic_ax.plot(t, np.sin(t + time.time()))
51
self._timer = dynamic_canvas.new_timer(50)
52
self._timer.add_callback(self._update_canvas)
53
self._timer.start()
54
55
def _update_canvas(self):
- self._dynamic_ax.clear()
56
t = np.linspace(0, 10, 101)
- # Use fixed vertical limits to prevent autoscaling changing the scale
- # of the axis.
57
- self._dynamic_ax.set_ylim(-1.1, 1.1)
58
# Shift the sinusoid as a function of time.
59
- self._dynamic_ax.plot(t, np.sin(t + time.time()))
60
- self._dynamic_ax.figure.canvas.draw()
+ self._line.set_data(t, np.sin(t + time.time()))
+ self._line.figure.canvas.draw()
61
62
63
if __name__ == "__main__":
0 commit comments