您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在python matplotlib点(散点)图中添加趋势线?

如何在python matplotlib点(散点)图中添加趋势线?

这里解释

在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 2022/1/1 18:26:23 有286人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶