title: How do you plot the total summation of harmonics in python
body: <p>I am using the below manual method so as to plot the summation of harmonics. The below method is working fine.Please refer the image below.When the same thing implemented in for loop,it is not working as desired.The for loop is meant to take care of n number of harmonic values.Could any help me in this?</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  # omega =2*pi
  
  x=np.linspace(0,2*np.pi,2000)
  y1=np.sin(1*2*np.pi*x)/1
  y2=np.sin(3*2*np.pi*x)/3
  y3=np.sin(5*2*np.pi*x)/5
  y4=np.sin(7*2*np.pi*x)/7
  y5=np.sin(9*2*np.pi*x)/9
  Y=y1+y2+y3+y4+y5 
  plt.plot(x,Y)
  plt.grid()
  plt.show()
  
  #Implementation in for loop is not working
  
  def Harmonic(i):
      y = [] 
      for n in range(0,i):
          y=np.sin((2*n+1)*(2*np.pi)*(x))/(2*n+1)
          y += y
          plt.plot(x,y)
          plt.grid()
          plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/y0pQ4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y0pQ4.png" alt="Harmonics"></a></p>