I have the following data in result.csv file, and I need to plot into a line graph.
ColA ColB
93 46
94 56
95 66
97 76
100 86
103 96
110 106
What I have is
from numpy import genfromtxt
import matplotlib.pyplot as plt
per_data=genfromtxt('result.csv',delimiter=','
plt.xlabel ('x stuff')
plt.ylabel ('y stuff')
plt.title('my test result')
plt.show()
How do feed each column of data into the graph and see its trend? The size if each column will grow daily because of new data.
First, you need to separate your data using a comma, to make it an actual csv. Then add the missing closing brace at the end of this line:
per_data=genfromtxt('result.csv',delimiter=',')
and plot the data using
plt.plot(per_data)
This results in this plot:
When you add more data and run the code again it should automatically appear without any change in code.
from matplotlib import pyplot as plt
from matplotlib import style
from numpy import genfromtxt
data = genfromtxt('example2.csv',delimiter=' ')
plt.plot(data)
plt.title('Epic Info')
plt.ylabel('Y axis')
plt.xlabel('X axis')
plt.show()
The above code generated this ::
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With