Ich bin ganz neu ... habe es schon geschafft meine ersten Plots zu plotten. Doch jetzt stehe ich vor einem Problem! Ich habe diesen Code:
Code: Alles auswählen
import numpy as np
import matplotlib.pyplot as plt
with open("dataafl") as f:
data = f.read()
data = data.split('\n')
Temp = [row.split(' ')[0] for row in data]
X1 = [row.split(' ')[1] for row in data]
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_title("Plot title...")
ax1.set_xlabel('your x label..')
ax1.set_ylabel('your y label...')
ax1.plot(Temp,X1, c='r', label='the data')
leg = ax1.legend()
plt.show()
Dadurch bekomme ich folgende Fehlermeldung:#Temp X1 X2
309.820 0.473 0.529
309.422 0.400 0.601
309.031 0.371 0.625
308.006 0.326 0.657
306.686 0.293 0.690
304.553 0.255 0.724
301.803 0.218 0.758
299.097 0.193 0.783
296.000 0.168 0.804
294.534 0.157 0.814
Was mache ich falsch? Ich würde gerne X1, Temp und X2, Temp in einem Plot haben. Danach würde ich gerne einen Curvefit [Regression nach einem Polynomium dritten Grades] machen (für beide Plots einzeln) und das dann sichtbar auf dem Graph machen. Hoffentlich kann mir hier Jemand helfen?Traceback (most recent call last):
File "/home/basilius/MEGAsync/Q5/plot_aflv4", line 10, in <module>
X1 = [row.split(' ')[1] for row in data]
IndexError: list index out of range
[Finished in 0.4s]
Viele liebe Grüße!