我如何用一个X(时间)从Excel文件在python中绘制几个数据集



[在这里输入图像描述][1]我有一个excel数据集,有5列和300多行(来自excel文件):我正在尝试绘制[1:]列的y vs. x图(线),而第0列是'时间'(0:300+行)。

Time cycle1 cycle2 cycle 3 cycle4…周期15

0 0.5 0.2 0.5 0.4…0.55

1 0.51 0.21 0.52 0.43…0.6
。.

我的代码到目前为止没有工作(加上它太长,我找不到更好的方法使它更好)。我需要你的帮助!提前谢谢你!!

df = pd.read_excel(io.BytesIO(uploaded['Book1.xlsx']))
x = df['Time']
y1 = df['cycle 1']
y2 = df['cycle 2']
y3 = df['cycle 3']
y4 = df['cycle 4']
y5 = df['cycle 5']
y6 = df['cycle 6']
y7 = df['cycle 7']
y8 = df['cycle 8']
y9 = df['cycle 9']
y10 = df['cycle 10']
y11 = df['cycle 11']
y12 = df['cycle 12']
y13 = df['cycle 13']
y14 = df['cycle 14']
y15 = df['cycle 15']
plt.plot(x,y1, y2, y3,y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15 )
plt.show()```

[1]: https://i.stack.imgur.com/QGMZM.png

也许你需要的是理解:

[plt.plot(df['Time'], df[f'cycle {i}']) for i in range(1, len(df.columns))]

最新更新