如何将趋势线添加到使用 matplotlib.scatter 绘制的点图中?
最佳答案
如解释 here
在 numpy 的帮助下,可以计算例如线性拟合。
# plot the data itself
pylab.plot(x,y,'o')
# calc the trendline
z = numpy.polyfit(x, y, 1)
p = numpy.poly1d(z)
pylab.plot(x,p(x),"r--")
# the line equation:
print "y=%.6fx+(%.6f)"%(z[0],z[1])
关于python - 如何在 python matplotlib 点(散点图)图中添加趋势线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26447191/