| 
            
              
            
         | 
         The Python Book
     | 
    
      
      |    | 
      
Plot with simple legend
Use 'label' in your plot() call. 
import math
import matplotlib.pyplot as plt
xv= map( lambda x: (x/4.)-10., range(0,81))
for l in [ 0.1, 0.5, 1., 5.] :
    yv= map( lambda x: math.exp((-(-x)**2)/l), xv)
    plt.plot(xv,yv,label='lambda = '+str(l));
plt.legend() 
plt.show() 
Sidenote: the function plotted is that of the Gaussian kernel in weighted nearest neighour regression, with xi=0 
 
       |   |