@@ -29,7 +29,6 @@ def visualize(u, t, I, w):
2929 plot (t , u , "r--o" )
3030 t_fine = linspace (0 , t [- 1 ], 1001 ) # very fine mesh for u_e
3131 u_e = exact_solution (t_fine , I , w )
32- hold ("on" )
3332 plot (t_fine , u_e , "b-" )
3433 legend (["numerical" , "exact" ], loc = "upper left" )
3534 xlabel ("t" )
@@ -100,8 +99,6 @@ def main():
10099 parser .add_argument ("--dt" , type = float , default = 0.05 )
101100 parser .add_argument ("--num_periods" , type = int , default = 5 )
102101 parser .add_argument ("--savefig" , action = "store_true" )
103- # Hack to allow --SCITOOLS options (read when importing scitools.std)
104- parser .add_argument ("--SCITOOLS_easyviz_backend" , default = "matplotlib" )
105102 a = parser .parse_args ()
106103 I , w , dt , num_periods , savefig = a .I , a .w , a .dt , a .num_periods , a .savefig
107104 P = 2 * pi / w # one period
@@ -122,7 +119,6 @@ def plot_empirical_freq_and_amplitude(u, t, I, w):
122119 a = amplitudes (minima , maxima )
123120 figure ()
124121 plot (range (len (p )), 2 * pi / p , "r-" )
125- hold ("on" )
126122 plot (range (len (a )), a , "b-" )
127123 plot (range (len (p )), [w ] * len (p ), "r--" )
128124 plot (range (len (a )), [I ] * len (a ), "b--" )
@@ -144,8 +140,9 @@ def visualize_front(u, t, I, w, savefig=False):
144140 curves as they evolve in time.
145141 Makes it easy to plot very long time series.
146142 """
147- import scitools .std as st
148- from scitools .MovingPlotWindow import MovingPlotWindow
143+ import matplotlib .pyplot as plt
144+
145+ from compat .moving_plot_window import MovingPlotWindow
149146
150147 P = 2 * pi / w # one period
151148 umin = 1.2 * u .min ()
@@ -156,21 +153,18 @@ def visualize_front(u, t, I, w, savefig=False):
156153 for n in range (1 , len (u )):
157154 if plot_manager .plot (n ):
158155 s = plot_manager .first_index_in_plot
159- st .plot (
160- t [s : n + 1 ],
161- u [s : n + 1 ],
162- "r-1" ,
163- t [s : n + 1 ],
164- I * cos (w * t )[s : n + 1 ],
165- "b-1" ,
166- title = f"t={ t [n ]:6.3f} " ,
167- axis = plot_manager .axis (),
168- show = not savefig ,
169- ) # drop window if savefig
156+ plt .clf ()
157+ plt .plot (t [s : n + 1 ], u [s : n + 1 ], "r-" )
158+ plt .plot (t [s : n + 1 ], I * cos (w * t )[s : n + 1 ], "b-" )
159+ plt .title (f"t={ t [n ]:6.3f} " )
160+ plt .axis (plot_manager .axis ())
170161 if savefig :
171162 filename = "tmp_vib%04d.png" % n
172- st .savefig (filename )
163+ plt .savefig (filename )
173164 print ("making plot file" , filename , f"at t={ t [n ]:g} " )
165+ else :
166+ plt .draw ()
167+ plt .pause (0.001 )
174168 plot_manager .update (n )
175169
176170
@@ -182,7 +176,7 @@ def visualize_front_ascii(u, t, I, w, fps=10):
182176 """
183177 import time
184178
185- from scitools . avplotter import Plotter
179+ from compat . ascii_plotter import Plotter
186180
187181 P = 2 * pi / w
188182 umin = 1.2 * u .min ()
0 commit comments