参数设置

  1. import matplotlib.pyplot as plt
  2. y_hat = w*x+b
  3. plt.figure(figsize=(8,5),dpi=80)
  4. plt.xlabel("time")
  5. plt.ylabel("the voltage under log ")
  6. plt.scatter(x,y,c='red',s=2, alpha=0.8)
  7. plt.plot(x,y_hat)

image.png

画子图

  1. from matplotlib import pyplot as plt
  2. import math
  3. b=[math.sin(x)+x for x in a]
  4. plt.plot(b)
  5. fig ,axs = plt.subplots(2,3)
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. def logistic(r=0.5,x_m=100,x_0=10,t=1):
  4. return x_m/(1+(x_m/x_0-1)*np.exp(-r*t))
  5. para1={'r':0.5,'x_m':1000,'x_0':10}
  6. para2={'r':2,'x_m':1000,'x_0':10}
  7. para3={'r':5,'x_m':1000,'x_0':10}
  8. para4={'r':0.5,'x_m':100,'x_0':10}
  9. para5={'r':0.5,'x_m':1000,'x_0':10}
  10. para6={'r':0.5,'x_m':10000,'x_0':10}
  11. t = np.linspace(0,50)
  12. x = logistic(**para1,t=t)
  13. fig,axs =plt.subplots(2,3,figsize=(24,16))
  14. axs[0][0].plot(t,logistic(**para1,t=t))
  15. axs[0][1].plot(t,logistic(**para2,t=t))
  16. axs[0][2].plot(t,logistic(**para3,t=t))
  17. axs[1][0].plot(t,logistic(**para4,t=t))
  18. axs[1][1].plot(t,logistic(**para5,t=t))
  19. axs[1][2].plot(t,logistic(**para6,t=t))
  20. axs[0][0].set(title="r=0.5",xlabel="t",ylabel="x")
  21. axs[0][1].set(title="r=1.0",xlabel="t",ylabel="x")
  22. axs[0][2].set(title="r=2.0",xlabel="t",ylabel="x")
  23. axs[1][0].set(title="x_m=100,r=0.5",xlabel="t",ylabel="x")
  24. axs[1][1].set(title="x_m=1000,r=0.5",xlabel="t",ylabel="x")
  25. axs[1][2].set(title="x_m=10000,r=0.5",xlabel="t",ylabel="x")
  26. para7={'r':0.202,'x_m':392.09,'x_0':3.9}
  27. def turn_point(r,x_m,x_0):
  28. return np.log(x_m/x_0-1)/r
  29. turn_point(**para7)