plot when we wanted multiple curves in single windowwhich is not what we want here insteadwe need to create an object that represents the plot and then update the -values of this object for each pass through the loop the complete code can look like import matplotlib pyplot as plt import numpy as np def (xms)return ( /(np sqrt( *np pi)* ))*np exp(- *(( - )/ )** s_start s_stop s_values np linspace(s_starts_stop np linspace( - *s_startm *s_start is max for = (smaller gives larger max valuemax_f (mms_stopy ( , ,s_stoplines plt plot( , #returns list of line objectsplt axis([ [ ] [- ]- max_f]plt xlabel(' 'plt ylabel(' 'for in s_valuesy (xmslines[ set_ydata( #update plot data and redraw plt draw(plt pause( most of the lines in this code should be familiarbut there are few items that are worth noting firstwe use the same plot function as earlierbut in slightly different manner generallythis function does two thingsit creates plot that is ready to display on the screen by subsequent call to show()and it returns special matplotlib object that represents the plot ( line objectin the examples abovewe did not need this objectso we did not care about itbut this time we store it in the variable lines note also that the plot-function always returns list of such objectsrepresenting all the curves of the plot in this casewe plot only one curveand the list has length one to update the plot inside the for loopwe call the set_ydata method of this objectthat islines[ set_ydata( )every time we have computed new array after updating the datawe call the function draw(to draw the curve on the screen the final line inside the for loop simply makes the program stop and wait for seconds if we remove this callthe movie runs too fast to be visibleand we can obviously adjust the speed by changing the function' argument as final comment on this coderemember the important message from abovethat we always need to fix the axes when creating moviesotherwisematplotlib will adjust the axes automatically for each plotand the resulting movie will not really look like movie at all