Advertisement
Korotkodul

B. Сердечная задача

Mar 21st, 2025
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. plt.style.use("ggplot")
  4. from json import loads
  5.  
  6. file = open("medic_data.json")
  7. data = loads(file.read())
  8. before = data['before']
  9. after = data['after']
  10. degrees_of_mitral_regurgitation = ['I', 'II', 'III', 'IV']
  11. width = 0.3
  12. x = np.arange(4)
  13. fig, axis = plt.subplots()
  14. print(before)
  15. print(after)
  16. degrees = np.array([['I'], ['II'], ['III'], ['IV']])
  17. before_cnt = np.sum((np.array(before == degrees)), axis=1)
  18. after_cnt = np.sum((np.array(after == degrees)), axis=1)
  19. print(before_cnt)
  20. print(after_cnt)
  21. rects_before = axis.bar(x - width/2, before_cnt, width, label = 'before', color = 'sandybrown')
  22. rects_after =  axis.bar(x + width/2, after_cnt, width, label = 'after', color = 'cornflowerblue')
  23. axis.set_title('Mitral disease stages', fontsize=17, fontweight="bold", c="dimgray")
  24. axis.set_ylabel("amount of people", fontsize=10, fontweight="bold", c="dimgray")
  25. axis.set_xticks(x)
  26. axis.set_xticklabels(degrees_of_mitral_regurgitation)
  27. axis.legend()
  28. plt.show()
  29.  
  30. fig.savefig('Mitral disease stages.png', bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement