擅长:python、mysql、java
<p>看起来您正在尝试将第一列绘制为x,第二列绘制为y。你在索引上犯了个错误。要获得datf的第一列,需要执行<code>datf[:, 0]</code>(注意逗号)</p>
<p>最终代码如下所示:</p>
<pre><code> import numpy as np
import matplotlib.pyplot as plt
datf=np.loadtxt(filename, dtype=float,delimiter=" ")
print((datf))
plt.plot(datf[:, 0], datf[:, 1]) # note the commas here
plt.show()
</code></pre>