Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 65497d3

Browse filesBrowse files
committed
Make zooming work in qt-embedding example.
Calling set_ylim everytime in _update_canvas breaks interactive zoom.
1 parent 9e20541 commit 65497d3
Copy full SHA for 65497d3

File tree

Expand file treeCollapse file tree

1 file changed

+5
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-6
lines changed

‎examples/user_interfaces/embedding_in_qt_sgskip.py

Copy file name to clipboardExpand all lines: examples/user_interfaces/embedding_in_qt_sgskip.py
+5-6Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.