Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- from scipy import optimize
- get_ipython().run_line_magic('matplotlib', 'inline')
- fig,ax = plt.subplots(figsize=(16,8))
- f=np.poly1d([5,1])
- x=np.linspace(0,20,30)
- y=f(x)+6*np.random.normal(size=len(x))
- m,c=np.polyfit(x,y,1)
- xn=np.linspace(0,20,200)
- yn=np.polyval([m,c],xn)
- ##see the legend carefully, then open the another code and do side by side comparison##
- ax.plot(x,y,"ob",label="data")
- ax.plot(xn,yn,label="polyfit",color="black")
- ax.plot(x,y,label="ntg")
- ax.plot(xn_1,yn,"red",label="polyfit12",)
- ax.legend(ncol=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement