问题描述
我希望 x 轴是温度值所在的行,y 轴是实际值。 我该怎么做呢? 我将文件中的值打印到一列中。
1楼
import matplotlib.pyplot as plt
# get data
with open("data.txt") as myfile:
temps = [float(row) for row in myfile]
# generate line numbers
num_rows = len(temps)
rownums = list(range(num_rows)) # starting at 0!
# plot
plt.plot(rownums, temps)
plt.show()
这使