因此,我正在尝试编写一个代码,该代码将从文本文件中导入数据并使用 matplotlib 绘制它,这是我目前所拥有的:
import matplotlib.pyplot as plt
x = []
y = []
readFile = open ('C:/Users/Owner/Documents/forcecurve.txt', 'r')
sepFile = readFile.read().split('\n')
readFile.close()
for plotPair in sepFile:
xAndY = plotPair.split('\t')
x.append(int (xAndY[0]))
y.append(int (xAndY[1]))
print x
print y
plt.plot (x, y)
plt.xlabel('Distance (Nanometers)')
plt.ylabel('Force (Piconewtons)')
plt.show()
一旦运行这个我得到错误
ValueError: invalid literal for int() with base 10: '1,40.9'