📜  添加趋势线以绘制 matplotlib - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:55.852000             🧑  作者: Mango

代码示例1
# 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])