File tree 1 file changed +5
-6
lines changed 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -45,19 +45,18 @@ def __init__(self):
45
45
self ._static_ax .plot (t , np .tan (t ), "." )
46
46
47
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 ()))
48
51
self ._timer = dynamic_canvas .new_timer (50 )
49
52
self ._timer .add_callback (self ._update_canvas )
50
53
self ._timer .start ()
51
54
52
55
def _update_canvas (self ):
53
- self ._dynamic_ax .clear ()
54
56
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 )
58
57
# 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 ()
61
60
62
61
63
62
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments