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

Skip to content

Commit 9c89f7a

Browse files
authored
Merge pull request #17353 from anntzer/qtex
Make zooming work in qt-embedding example.
2 parents 9e20541 + 65497d3 commit 9c89f7a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/user_interfaces/embedding_in_qt_sgskip.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,18 @@ def __init__(self):
4545
self._static_ax.plot(t, np.tan(t), ".")
4646

4747
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()))
4851
self._timer = dynamic_canvas.new_timer(50)
4952
self._timer.add_callback(self._update_canvas)
5053
self._timer.start()
5154

5255
def _update_canvas(self):
53-
self._dynamic_ax.clear()
5456
t = np.linspace(0, 10, 101)
55-
# Use fixed vertical limits to prevent autoscaling changing the scale
56-
# of the axis.
57-
self._dynamic_ax.set_ylim(-1.1, 1.1)
5857
# 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()
58+
self._line.set_data(t, np.sin(t + time.time()))
59+
self._line.figure.canvas.draw()
6160

6261

6362
if __name__ == "__main__":

0 commit comments

Comments
 (0)