我成功了!谢谢你的评论。这是更新的代码。#!/usr/bin/python
import matplotlib.pyplot as plt
import time
import numpy as np
from scipy.interpolate import spline
# Local variables
x = []
y = []
# Open the data file for reading lines
datafile = open('testdata1.txt', 'r')
sepfile = datafile.read().split('\n')
datafile.close()
# Create a canvas to place the subgraphs
canvas = plt.figure()
rect = canvas.patch
rect.set_facecolor('white')
# Iterate through the lines and parse them
for datapair in sepfile:
if datapair:
xypair = datapair.split(' ')
x.append(int(xypair[1]))
y.append(int(xypair[3]))
x_sm = np.array(x)
y_sm = np.array(y)
x_smooth = np.linspace(x_sm.min(), x_sm.max(), 200)