title: How to fix the issue of plotting a 2D sine wave in python
body: <p>I want to generate 2D travelling sine wave. To do this, I've set the parameters for the plane wave and generate wave for any time instants like as follows:</p>
  <pre class="lang-python prettyprint-override"><code>import numpy as np
  import random
  import matplotlib.pyplot as plt
  f = 10         # frequency
  fs = 100       # sample frequency
  Ts = 1/fs      # sample period
  t = np.arange(0,0.5, Ts)   # time index
  c = 50             # speed of wave
  w = 2*np.pi *f     # angular frequency
  k = w/c            # wave number
  
  resolution = 0.02
  x = np.arange(-5, 5, resolution)
  y = np.arange(-5, 5, resolution)
  dx = np.array(x); M = len(dx)
  dy = np.array(y); N = len(dy)
  [xx, yy] = np.meshgrid(x, y);
  theta = np.pi / 4         # direction of propagation
  kx =  k* np.cos(theta)
  ky = k * np.sin(theta)
  </code></pre>
  <p>So, the plane wave would be</p>
  <pre><code>plane_wave = np.sin(kx * xx + ky * yy - w * t[1])
  plt.figure(); 
  plt.imshow(plane_wave,cmap='seismic',origin='lower', aspect='auto')
  </code></pre>
  <p>that gives a smooth plane wave as shown in  <a href="https://i.stack.imgur.com/HD5jb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HD5jb.png" alt="figure 01" /></a>. Also, the sine wave variation with <code>plt.figure(); plt.plot(plane_wave[2,:])</code> time is given in <a href="https://i.stack.imgur.com/akrMj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/akrMj.png" alt="figure 02" /></a>.
  However, when I want to append plane waves at different time instants then there is some discontinuity arises in figure 03<a href="https://i.stack.imgur.com/b1P1v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b1P1v.png" alt="time discontinuity" /></a> &amp; 04 <a href="https://i.stack.imgur.com/WginR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WginR.png" alt="discontinuity in plane wave w.r.t. time" /></a>, and I want to get rid of from this problem.</p>
  <p>I'm new in python and any help will be highly appreciated. Thanks in advance.</p>
  <pre class="lang-python prettyprint-override"><code>arr = []
  for count in range(len(t)):
      p = np.sin(kx * xx + ky * yy - w * t[count]); # plane wave
      arr.append(p)
  arr = np.array(arr)
  print(arr.shape)
  pp,q,r = arr.shape
  sig = np.reshape(arr, (-1, r))
  print('The signal shape is :', sig.shape)
  
  plt.figure(); plt.imshow(sig.transpose(),cmap='seismic',origin='lower', aspect='auto')
  plt.xlabel('X'); plt.ylabel('Y')
  plt.figure(); plt.plot(sig[2,:])
  </code></pre>