Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- plt.style.use("ggplot")
- from json import loads
- file = open("medic_data.json")
- data = loads(file.read())
- before = data['before']
- after = data['after']
- degrees_of_mitral_regurgitation = ['I', 'II', 'III', 'IV']
- width = 0.3
- x = np.arange(4)
- fig, axis = plt.subplots()
- print(before)
- print(after)
- degrees = np.array([['I'], ['II'], ['III'], ['IV']])
- before_cnt = np.sum((np.array(before == degrees)), axis=1)
- after_cnt = np.sum((np.array(after == degrees)), axis=1)
- print(before_cnt)
- print(after_cnt)
- rects_before = axis.bar(x - width/2, before_cnt, width, label = 'before', color = 'sandybrown')
- rects_after = axis.bar(x + width/2, after_cnt, width, label = 'after', color = 'cornflowerblue')
- axis.set_title('Mitral disease stages', fontsize=17, fontweight="bold", c="dimgray")
- axis.set_ylabel("amount of people", fontsize=10, fontweight="bold", c="dimgray")
- axis.set_xticks(x)
- axis.set_xticklabels(degrees_of_mitral_regurgitation)
- axis.legend()
- plt.show()
- fig.savefig('Mitral disease stages.png', bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement