title: Buggy behavior in matplotlib pcolormesh with FFT arrays?
body: <p>I am trying to reproduce the example of the Gabor transform that it is in his wikipedia entry, and I do not know if it is a bug or I am missing something. The example is the calculate the Gabor transform of a sinusoidal signal:</p>
  
  <p><img src="https://i.stack.imgur.com/MOMLm.png" alt="The function"></p>
  
  <p>To plot the frequencies sorted, I create an unsorted axis. Then I use mesh grid to create 2D axes and plot with pcolormesh. Here is the piece of the code:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.gridspec as gridsp
  
  dt = 0.05
  x = np.arange(-50.0,50.0,dt)
  y = np.sin(2.0 * np.pi * x)
  Nx = len(x)
  w = np.fft.fftfreq(Nx,dt)
  
  sigma = 1.0 / 3.0 
  neg = np.where (x &lt;= 0.0)
  pos = np.where (x &gt; 0.0)
  
  T,W = np.meshgrid(x,w)
  func = np.zeros(Nx)
  tmp = np.zeros(Nx,dtype='complex64')
  gabor = np.zeros((Nx,Nx))
  
  func[neg] = np.sin(2.0 * np.pi * x[neg])
  func[pos] = np.sin(4.0 * np.pi * x[pos])
  
  for it in range(Nx):    
          tmp[:] = np.fft.fft(func[:] * np.exp( - ( x[it] - x[:] ) * ( x[it] - x[:] ) / 2.0 / sigma / sigma ) ) 
  
          gabor[:,it] = np.real(np.conj(tmp) * tmp)
  
  fig = plt.figure(figsize=(20,10),facecolor='white')
  gs = gridsp.GridSpec(2, 1)
  
  ax1 = plt.subplot(gs[0,0])
  ax1.plot(x,func,'r',linewidth=2)
  ax1.axis('tight')
  ax1.set_xticks(np.arange(min(x),max(x),1.) )
  ax1.set_xlabel('time',fontsize=20)
  ax1.set_ylabel(r'$\sin{time}$',fontsize=20)
  ax1.set_xlim([-6.0,6.0])
  
  
  ax2 = plt.subplot(gs[1,0])
  surf1 = ax2.pcolormesh(T,W,gabor,shading='gouraud')
  ax2.axis('tight')
  ax2.set_xticks(np.arange(min(x),max(x),2.) )
  ax2.set_yticks(np.arange(min(w),max(w),2.) )
  ax2.set_xlabel('time',fontsize=20)
  ax2.set_ylabel('frequency',fontsize=20)
  ax2.set_xlim([-6.0,6.0])
  ax2.set_ylim([-4.0,4.0])
  
  gs.tight_layout(fig)
  plt.show()
  </code></pre>
  
  <p>Here is the figure I get,</p>
  
  <p><img src="https://i.stack.imgur.com/KuAYP.png" alt="Only negative frequencies. The lower part of the array is plotted"></p>
  
  <p>It seems that the upper part of the plot is reduced to zero. If I try it using fftshift when I create the transform and the axis,</p>
  
  <pre><code>for it in range(Nx):
          tmp[:] = np.fft.fftshift(np.fft.fft(func[:] * np.exp( - ( x[it] - x[:] ) * ( x[it] - x[:] ) / 2.0 / sigma / sigma ) ) )     
  
  
          gabor[:,it] = np.real(np.conj(tmp) * tmp)
  
  T,W = np.meshgrid(x,np.fft.fftshift(w))
  </code></pre>
  
  <p>Then I get this figure:</p>
  
  <p><img src="https://i.stack.imgur.com/akEtR.png" alt="Finally, the right figure">!</p>
  
  <p>It seems that pcolormesh routine can not flip upside down the array as it is usually done in 1D plots. does anybody know exactly why it is doing this?</p>
  
  <p>Thanks,</p>
  
  <p>Alex </p>