Created
October 10, 2017 12:33
-
-
Save urigoren/7188607d761ce2386e5507842dd7c891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
def polyfit_plot(x, y, p=1): | |
plt.scatter(x, y) | |
axes = plt.gca() | |
coeff = np.polyfit(x, y, p) | |
X_plot = np.linspace(axes.get_xlim()[0],axes.get_xlim()[1],100) | |
print (np.corrcoef(x,y)[0,1]) | |
Y_plot = 0 | |
for c in coeff: | |
Y_plot = X_plot*Y_plot + c | |
plt.plot(X_plot, Y_plot, '-') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment