File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
6362if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments