make_invited_plot.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/usr/bin/env python
  2. import sys
  3. import json
  4. import lzma
  5. import datetime
  6. import numpy as np
  7. import matplotlib
  8. import matplotlib.pyplot as pyplot
  9. import matplotlib.colors as mcolors
  10. def main():
  11. set_plot_options()
  12. days=np.arange(180)
  13. ft = []
  14. # initialize users to 20
  15. users = 20
  16. total_users = users
  17. g = 0
  18. h = 0
  19. i = 0
  20. g_two = 0
  21. h_two = 0
  22. i_two = 0
  23. g_two_two = 0
  24. h_two_two = 0
  25. i_two_two = 0
  26. g_two_four = 0
  27. h_two_four = 0
  28. i_two_four = 0
  29. g_four = 0
  30. g_four_two = 0
  31. h_four = 0
  32. i_four = 0
  33. g_six = 0
  34. h_six = 0
  35. i_six = 0
  36. g_users = 0
  37. h_users = 0
  38. i_users = 0
  39. g_two_users = 0
  40. h_two_users = 0
  41. pyplot.figure()
  42. for f in days:
  43. if g > 1:
  44. g = g+1
  45. if h > 1:
  46. h = h+1
  47. if g_two > 1:
  48. g_two = g_two+1
  49. if h_two > 1:
  50. h_two = h_two+1
  51. if g_two_two > 1:
  52. g_two_two = g_two_two+1
  53. if h_two_two > 1:
  54. h_two_two = h_two_two+1
  55. if g_two_four > 1:
  56. g_two_four = g_two_four+1
  57. if h_two_four > 1:
  58. h_two_four = h_two_four+1
  59. if g_four > 1:
  60. g_four = g_four+1
  61. if g_four_two > 1:
  62. g_four_two = g_four_two+1
  63. if f == 72:
  64. g = 44
  65. g_users = users*2
  66. total_users = total_users+g_users
  67. if f == 128:
  68. h= 44
  69. h_users = users*4
  70. total_users = total_users+h_users
  71. if g == 72:
  72. g_two_users = g_users * 2
  73. total_users = total_users+g_two_users
  74. g_two = 44
  75. if g_two == 72:
  76. g_two_two = 44
  77. g_two_two_users = g_two_users*2
  78. total_users = total_users+g_two_two_users
  79. if g_two_two == 72:
  80. g_six_users = g_two_two_users*2
  81. total_users = total_users+g_six_users
  82. if h == 72:
  83. h_two_users = h_users * 2
  84. total_users = total_users+h_two_users
  85. h_two =44
  86. if g == 128:
  87. g_four = 44
  88. g_four_users = g_users* 4
  89. total_users = total_users+g_four_users
  90. if h_two == 72:
  91. h_two_two = 44
  92. h_two_two_users = h_two_users*2
  93. total_users = total_users+h_two_two_users
  94. if g_four == 72:
  95. g_four_two = 44
  96. g_four_two_users = g_four_users*2
  97. total_users = total_users+g_four_two_users
  98. x = total_users
  99. ft.append(x)
  100. pyplot.plot(days, ft, label='Invited Users')
  101. pyplot.ylabel("Users")
  102. pyplot.xlabel("Number of Days")
  103. # pyplot.title("Average Number of Bridge Users for 1 Month Old Bridges November 2021")
  104. # pyplot.legend(title="Protocols", loc="upper left")
  105. pyplot.tight_layout(pad=1)
  106. pyplot.savefig("invited-users.pdf")
  107. def set_plot_options():
  108. options = {
  109. #'backend': 'PDF',
  110. 'font.size': 12,
  111. 'figure.figsize': (7,5),
  112. 'figure.dpi': 100.0,
  113. 'axes.grid' : True,
  114. 'axes.xmargin' : 0.01,
  115. 'axes.grid.axis' : 'y',
  116. 'axes.axisbelow': True,
  117. 'axes.titlesize' : 'medium',
  118. 'axes.labelsize' : 'large',
  119. 'axes.formatter.limits': (-6,6),
  120. 'xtick.labelsize' : 10,#get_tick_font_size_10(),
  121. 'ytick.labelsize' : 10,
  122. 'lines.linewidth' : 2.0,
  123. 'lines.markersize' : 10,
  124. # turn on the following to embedd fonts; requires latex
  125. 'ps.useafm' : True,
  126. 'pdf.use14corefonts' : True,
  127. 'text.usetex' : False,
  128. }
  129. for option_key in options:
  130. matplotlib.rcParams[option_key] = options[option_key]
  131. if 'figure.max_num_figures' in matplotlib.rcParams:
  132. matplotlib.rcParams['figure.max_num_figures'] = 100
  133. if 'figure.max_open_warning' in matplotlib.rcParams:
  134. matplotlib.rcParams['figure.max_open_warning'] = 100
  135. if 'legend.ncol' in matplotlib.rcParams:
  136. matplotlib.rcParams['legend.ncol'] = 100
  137. if __name__ == "__main__":
  138. sys.exit(main())