Download Stack/Stack_3e1a480eaa7282e9/code_edit.py from AIHero123/ChartM3: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_3e1a480eaa7282e9/code_edit.py
- Command line
-
hf download hf://datasets/AIHero123/ChartM3/Stack/Stack_3e1a480eaa7282e9/code_edit.py
-
curl -L -o code_edit.py https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_3e1a480eaa7282e9/code_edit.py
1.04 kB
| import matplotlib.pyplot as plt | |
| # Sleep Quality Levels | |
| quality_levels = ['Poor', 'Fair', 'Good', 'Excellent'] | |
| # Daily Caffeine Consumption | |
| low_consumption = [10, 20, 30, 15] # Low | |
| moderate_consumption = [15, 25, 40, 20] # Moderate | |
| high_consumption = [5, 15, 25, 10] # High | |
| # Define the colors for different consumption levels | |
| colors = ["#1f77b4", "#ff7f0e", "#2ca02c"] | |
| # Create the stackplot | |
| plt.figure(figsize=(10, 7)) | |
| plt.stackplot(quality_levels, low_consumption, moderate_consumption, high_consumption, labels=['Low','Moderate','High'], colors=colors) | |
| # Apply modifications to the target object | |
| for i, area in enumerate(plt.gca().collections): | |
| if i == 1: # Moderate consumption stack | |
| area.set_animated(True) | |
| area.set_clip_on(True) | |
| # Define labels and title | |
| plt.xlabel('Sleep Quality Level') | |
| plt.ylabel('Number of Students') | |
| plt.title('Sleep Quality and Daily Caffeine Consumption among College students') | |
| # Display the legend | |
| plt.legend(loc='upper left') | |
| plt.tight_layout() | |
| plt.savefig("Edit_figure.png") |