我有一个包含 5 列的文本文件。第 1 列是 X 轴(1,2,3,4),其余列是 y 轴。我想将它们绘制在一张图中。
1 0 0 0 0
2 7 14 2.53381 0.0691848
3 6 16 2.61242 0.0507856
4 6 17 2.65154 0.040285
我正在尝试将此代码用于单个y值。
import matplotlib.pyplot as plt
import numpy as np
file_name = input("Enter the file name:")
x, y = np.loadtxt(file_name, delimiter=',', unpack=True)
plt.plot(x,y, label='Loaded from file!')
plt.xlabel('Action')
plt.ylabel('Rate')
plt.title('Plot of Rate')
plt.legend()
plt.show()
如何y提取并绘制多个值?
眼眸繁星
慕哥9229398
慕勒3428872
Smart猫小萌
相关分类