Index: matplotlib/lib/matplotlib/axes.py =================================================================== --- matplotlib/lib/matplotlib/axes.py (revision 2793) +++ matplotlib/lib/matplotlib/axes.py (working copy) @@ -4267,7 +4267,11 @@ Pxx is a len(times) x len(freqs) array of power im is a matplotlib.image.AxesImage. - """ + + Note: If x is real (i.e. non-complex) only the positive spectrum is + shown. If x is complex both positive and negative parts of the + spectrum are shown. + """ if not self._hold: self.cla() Pxx, freqs, bins = matplotlib.mlab.specgram(x, NFFT, Fs, detrend, @@ -4279,7 +4283,7 @@ if xextent is None: xextent = 0, amax(bins) xmin, xmax = xextent - extent = xmin, xmax, 0, amax(freqs) + extent = xmin, xmax, amin(freqs), amax(freqs) im = self.imshow(Z, cmap, extent=extent) self.axis('auto') Index: matplotlib/lib/matplotlib/mlab.py =================================================================== --- matplotlib/lib/matplotlib/mlab.py (revision 2793) +++ matplotlib/lib/matplotlib/mlab.py (working copy) @@ -908,10 +908,13 @@ Compute a spectrogram of data in x. Data are split into NFFT length segements and the PSD of each section is computed. The windowing function window is applied to each segment, and the - amount of overlap of each segment is specified with noverlap + amount of overlap of each segment is specified with noverlap. See pdf for more info. + If x is real (i.e. non-Complex) only the positive spectrum is + given. If x is Complex then the complete spectrum is given. + The returned times are the midpoints of the intervals over which the ffts are calculated """ @@ -948,6 +951,10 @@ t = 1/Fs*(ind+NFFT/2) freqs = Fs/NFFT*arange(numFreqs) + if typecode(x) == Complex: + freqs = concatenate((freqs[NFFT/2:]-Fs,freqs[:NFFT/2])) + Pxx = concatenate((Pxx[NFFT/2:,:],Pxx[:NFFT/2,:]),0) + return Pxx, freqs, t def bivariate_normal(X, Y, sigmax=1.0, sigmay=1.0,