Plylab / MatPlotLib plot not showing data properly
<p>I have been following a tutorial to learn about fft and although I have the code verbatum, the plot from my machine does not look how it ought to.  I log the data to make sure that I have an approximate sine wav over 5292 samples.  However when I run the plot with <code>show()</code> I get the following image:  (btw, is there a markdown attr for making these images smaller?)</p>

<p><a href="http://i.stack.imgur.com/kWrO0.png" rel="nofollow"><img src="http://i.stack.imgur.com/kWrO0.png" alt="pyplot"></a></p>

<p>Again, this is generated from the subsequent code:</p>

<pre><code>from pylab import *
from scipy.io import wavfile


sampFreq, snd = wavfile.read('440_sine.wav')

snd = snd / (2.**15)

s1 = snd[:,0]

timeArray = arange(0, 5292, 1)
timeArray = timeArray / sampFreq
timeArray = timeArray * 1000  #scale to milliseconds


plot(timeArray, s1, color='k')
ylabel('Amplitude')
xlabel('Time (ms)')


for i in s1:
    print i

show()
</code></pre>

<p>In short, I'm learning about fft and I'm a newcomer to python/matplotlib, so any help is greatly appreciated in advance.</p>

<p>What is the value of your <code>sampFreq</code>? Your <code>timeArray</code> is an integer list and I am assuming sampFreq is returned an integer as well. If <code>sampFreq</code> is larger than the values in <code>timeArray</code> then all of the resultant values will be 0 because integer division. </p>

<p>You may want to cast <code>sampFreq</code> to a float first before diving through the <code>timeArray</code> list and see if that helps.</p>

<p>As an example of the issue, in python shell try out:</p>

<pre><code>&gt;&gt;&gt; 3/4
</code></pre>

<p>and</p>

<pre><code>&gt;&gt;&gt; 3/4.0
</code></pre>

python matplotlib