How do I properly plot data extracted from a scope as .csv file
<p>I just extracted a .csv file from a scope, which shows how a signal changes in the time duration of 6 seconds. Problem is that I can't come up with a proper way of plotting this signal, without things getting mushed together.</p>

<p>Mushed together like this:</p>

<p><a href="https://i.stack.imgur.com/XYYa9.png" rel="nofollow"><img src="https://i.stack.imgur.com/XYYa9.png" alt="Matplot screen shoot"></a></p>

<p>The .csv file is <a href="https://ufile.io/12a6" rel="nofollow">here</a>.</p>

<p>The signal goes through four stages, which I want to show with the plot, without it being to mushed together? How do I plot it?</p>

<p>More info about the signal:</p>

<p>The signal is a PWM signal that changes frequency. Either plotting the PWM signal vs. time, or the frequency of the PWM signal vs time, would be plot representation I would be /seeking for. </p>

<p>I don't know if this was intended, but the output of your signal simply oscillates between 0 and 1. I tried</p>

<pre><code>import numpy as np
a = np.genfromtxt('test.csv', delimiter=',')    #Using numpy to directly read csv file into numpy array. Also, I renamed the csv file to test.csv
a=a[1:]    #To remove the headers

print(np.nonzero(a[::2, 1]))
print(np.nonzero(a[1::2, 1]-1))
</code></pre>

<p>both yield empty lists, indicating all even positions have the value 1 and all odd indices have 0. That is why you see the mushed up plot.</p>

<p>So taking the mean of 1/4th the x-span(for four stages) and rendering it would be meaningless. So the only option you would be left with is to plot only a very small sub-section of your csv file</p>

<p>That can be easily done with just (assuming you want to plot from the 10th to the 20th value)</p>

<pre><code>plt.plot( a[10:20,0], a[10:20,1])
</code></pre>

<p><a href="https://i.stack.imgur.com/e546v.png" rel="nofollow"><img src="https://i.stack.imgur.com/e546v.png" alt="enter image description here"></a></p>

<p>An observation: although y-value jumps between 0 and 1 alternatively, x-value does not change in any pattern</p>

python matlab csv plot gnuplot