if conditionx elsex return def f_vectorized( ) np where(conditionx return this conversion is notof courseas automatic as using vectorizeand requires writing some more codebut it is much more computationally efficient than the other versions efficiency is sometimes important when working with large arrays making movie of plot it is often useful to make animations or movies of plotsfor instance if the plot represents some physical phenomenon that changes with timeor if we want to visualize the effect of changing parameters matplotlib has multiple tools for creating such plotsand we will explore some of them here to start with specific caseconsider again the well-known gaussian bell function  - exp (xms the parameter is the location of the function' peakwhile is measure of the width of the bell curve plots of this function for different values of are shown in figure as an alternative illustration of how the parameters change the function we can make movie (animationof how (xmschanges shape as goes from two to movies are made from large set of individual plots movies of plots are created through the classical approach of cartoon movies (orreallyall movies)by creating set of images and viewing them in rapid sequence for our specific examplethe typical approach is to write for loop to step through the values and either show the resulting plots directly or store them in individual files for later processing regardless of the approachit is important to always fix the axes when making animations of plotsotherwisethe axis always adapts to the peak of the function and the visual impression is completely wrong we will look at three different ways to create movie of the kind outlined above