How can I produce the graph below in Python? (I plotted in excel from a csv file
ID: 667268 • Letter: H
Question
How can I produce the graph below in Python? (I plotted in excel from a csv file.) Below are the 1st 10 entries for the csv file. The first column is time, the others are independent material stresses. I'm not skilled in Python yet, so please explain where needed.
0 0 0 0 0 0 0 0 0 0.0100101 6.08E-07 2.40E-06 1.33E-06 7.86E-05 7.47E-05 5.12E-05 4.50E-05 8.02E-06 0.0200202 1.22E-06 4.81E-06 2.67E-06 0.000157136 0.000149407 0.000102335 9.00E-05 1.60E-05 0.0300303 1.82E-06 7.21E-06 4.00E-06 0.000235704 0.00022411 0.000153502 0.000135052 2.41E-05 0.0400404 2.43E-06 9.61E-06 5.33E-06 0.000314272 0.000298813 0.00020467 0.000180069 3.21E-05 0.0500504 3.04E-06 1.20E-05 6.66E-06 0.00039284 0.000373516 0.000255837 0.000225086 4.01E-05 0.0600605 3.65E-06 1.44E-05 8.00E-06 0.000471408 0.00044822 0.000307004 0.000270103 4.81E-05 0.0700706 4.25E-06 1.68E-05 9.33E-06 0.000549976 0.000522923 0.000358172 0.00031512 5.61E-05 0.0800807 4.86E-06 1.92E-05 1.07E-05 0.000628544 0.000597626 0.000409339 0.000360138 6.42E-05 0.0900908 5.47E-06 2.16E-05 1.20E-05 0.000707112 0.00067233 0.000460506 0.000405155 7.22E-05Explanation / Answer
import numpy as np
data = np.genfromtxt('data.csv', delimiter=',', skip_header=10,
skip_footer=10, names=['a', 'b', 'c','d','e','f','g','h','i']) #reading data from csv file
figure = plt.figure()
axis1 = figure.add_subplot(111) #plot object declared
axis1.set_title("My Chart") #title declared
axis1.set_xlabel('Time')#labels declared
axis1.set_ylabel('Stresses')
axis1.plot(data['a'], data['b'],data['c'], data['d'],data['e'], data['f'],data['g'], data['h'],data['i'], color='r', label='the data')
leg = axis1.legend()
plt.show() #finally plotting
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.