Plot gyrosensor data in csv file in matplotlib
<p>I have exported gyro sensor data from my mobile using sensorLog app in csv format. I am trying the plot of three axis data wrt timestamp. Data looks like this </p>

<p>1474145797.91346    -0.055417   -0.465534   -0.284113</p>

<p>1474145797.93344    -0.108296   -0.42116    -0.240057</p>

<p>1474145797.95342    -0.047696   -0.424263   -0.247162</p>

<p>1474145797.99336    0.051028    -0.479374   -0.275701</p>

<p>Columns are timestamp, xaxis(rad/sec), yaxis(rad/sec), zaxis(rad/sec)</p>

<p>to plot this data I used the following python code:</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
xaxis, x, y, z = np.loadtxt('gyroscope.csv', delimiter=',', unpack = True)
plt.plot(xaxis, np.rad2deg(x), color = "blue", label = "xaxis")
plt.plot(xaxis, np.rad2deg(y), color = "red", label = "yaxis")
plt.plot(xaxis, np.rad2deg(z), color = "black", label = "zaxis")
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.show()
</code></pre>

<p>This is the error I get:<br>
return float(x)
ValueError: could not convert string to float: b'timestamp' . </p>

<p>However if I change the timestamp, the above code works fine which is not what i want. I want the graph of degrees with respect to time(millisec). I think the problem is with timestamp which is in format 1.47E+09. Could any one suggest me on how I can format the timestamp column? Am I missing anything?</p>

<p>Thanks in advance. Any suggestions or corrections is really appreciated.</p>

<p>I believe your Problem is the first line in the CSV-file which is actually the header.</p>

<p>Try passing <em>skiprows=1</em> to loadtxt</p>

python matplotlib