我在尝试正确格式化以绘制此图时遇到了一些麻烦。这就是我到目前为止所拥有的
from pylab import*
with open("spineprox.txt") as f:
data = f.read()
data = data.split('\n')
x = [column.split(' ')[0] for column in data]
y = [column.split(' ')[0] for column in data]
plt.title("Plot title...")
plt.xlabel('your x label..')
plt.ylabel('your y label...')
plt.plot(x,y, c='r', label='the data')
然后它会出现这个错误:ValueError: invalid literal for float(): 56.25 0.000000578
. 我不知道这个错误是什么意思。需要帮助请!
文本文件的格式如下:
56.25 0.000000578
56.2501 0.000003219
56.2502 0.000007031
56.2503 0.000001969
56.2504 0.000005641
56.2505 0.000006891
56.2506 0.000008656
56.2507 0.000005109
56.2508 0.000007937
56.2509 0.000006266
56.251 0.000009547
56.2511 0.000011828
56.2512 0.000007297
56.2513 0.000008641
56.2514 0.000008969
56.2515 0.000008234
56.2516 0.000007984
56.2517 0.000010266
56.2518 0.000004594
56.2519 0.000008469
56.252 0.000006297