Vitaliy_Novichikhin

Stepik 2.2.6Kapica

Jun 21st, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import math
  3.  
  4.  
  5. def compute_population(T1, t, tau, C):
  6.     under_atan = (T1 - t) / tau
  7.     arcctg = math.pi / 2 - math.atan(under_atan)
  8.     N_t = (C / tau) * arcctg
  9.     return N_t
  10.  
  11. C = 172  # billion man years
  12. T1 = 2000  # year 2K;
  13. tau = 45  # 45 years old;
  14.  
  15. range_start_a = 2000  # start of the range
  16. end_range_b = 2020  # End of the range
  17. n =20 #количество точек построения
  18. step_h = (end_range_b-range_start_a)/(n-1)  # calculate the step(dunno what the step)
  19.  
  20. # Let's form lists with argument values and function values in them
  21.  
  22. x_list = [range_start_a + step_h * i for i in range(n)]
  23. f_list = [compute_population(T1, t, tau, C) for t in x_list]
  24.  
  25. #5. Построим линию графика, установим для нее цвет и толщину:
  26.  
  27. line = plt.plot(x_list, f_list)
  28.  
  29. plt.setp(line, color="blue", linewidth=2)
  30. #6. Выведем 2 оси, установим для них позицию zero:
  31.  
  32. plt.gca().spines["left"].set_position("zero")
  33.  
  34. plt.gca().spines["bottom"].set_position("zero")
  35.  
  36. plt.gca().spines["top"].set_visible(False)
  37.  
  38. plt.gca().spines["right"].set_visible(False)
  39.  
  40. plt.show()
Add Comment
Please, Sign In to add comment