Run »
×
Change Orientation
# Import Libraries: import sys, matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np from scipy import stats x = np.array([50,60,70,80,90,100,110,120,130,140,150,160]) y = np.array([7,8,8,9,9,9,9,10,11,14,14,15]) # Name the Axis plt.title('House Prices vs Size') plt.xlabel('Square Meters') plt.ylabel('Price in Millions') # Call Linear Regression Function
slope, intercept, r, p, std_err = stats.linregress(x, y) # Plot Data plt.scatter(x, y) plt.plot(x, slope * x + intercept) plt.show() # Save and Flush the Plot plt.savefig(sys.stdout.buffer) sys.stdout.flush()
×
Report a Problem:
Your E-mail:
Page address:
Description:
Submit