2024-04-25 08:24:00 发布
网友
我正在写一个代码来寻找导入文件中某些数据的最佳拟合行的最小二乘法。直线的方程是ax+b,我已经计算了a和b。要绘制我尝试过的线条:
ax+b
a
b
LS_fit_ydata = [] for i in x_data: y_new = ((i*b) + a) LS_fit_ydata.append(y_new)
我用matplotlib.pyplot as plt来绘制我的图形。你知道吗
matplotlib.pyplot as plt
没有错误消息,但该行不会出现在我的图表上。有人知道怎么回事吗?谢谢你的帮助。你知道吗
您缺少的是代码中的绘图部分:
# The code you provided LS_fit_ydata = [] for i in x_data: y_new = ((i*b) + a) LS_fit_ydata.append(y_new) # What happens here is you're plotting x against y one by one via the list plt.plot(x_data, y_new) # Show the graph plt.show()
您缺少的是代码中的绘图部分:
相关问题 更多 >
编程相关推荐