Download Stack/Stack_3c55a592202bedb1/code_edit.py from AIHero123/ChartM3: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_3c55a592202bedb1/code_edit.py
- Command line
-
hf download hf://datasets/AIHero123/ChartM3/Stack/Stack_3c55a592202bedb1/code_edit.py
-
curl -L -o code_edit.py https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_3c55a592202bedb1/code_edit.py
1.03 kB
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| import matplotlib.patheffects as path_effects | |
| # Weekly data for different age groups | |
| weeks = [i for i in range(1, 27)] | |
| age_groups = ['0-10', '11-20', '21-30', '31-40', '41-50', '51-60', '61-70', '71-80', '80+'] | |
| cases = [np.linspace(25, 50, 26), | |
| np.linspace(50, 70, 26), | |
| np.linspace(70, 100, 26), | |
| np.linspace(90, 120, 26), | |
| np.linspace(120, 150, 26), | |
| np.linspace(100, 70, 26), | |
| np.linspace(80, 60, 26), | |
| np.linspace(60, 40, 26), | |
| np.linspace(40, 25, 26)] | |
| # Stack plot | |
| plt.figure(figsize=(10, 7)) | |
| plt.stackplot(weeks, cases, labels=age_groups) | |
| # Customize plot | |
| for i, area in enumerate(plt.gca().collections): | |
| if i == 2: # Target object | |
| area.set_visible(False) | |
| plt.xlabel('Weeks') | |
| plt.ylabel('Number of Cases') | |
| plt.title('Distribution of COVID-19 Cases Among Various Age Groups Over 6 Months') | |
| plt.legend(loc='upper left') | |
| # Display plot | |
| plt.tight_layout() | |
| plt.savefig("Edit_figure.png") |