Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add trendline to plot matplotlib

# 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])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #trendline #plot #matplotlib
ADD COMMENT
Topic
Name
8+9 =