Download Stack/Stack_3e1a480eaa7282e9/code.py from AIHero123/ChartM3: direct link, hf CLI and curl.
- Browser
- Download file 835 Bytes
-
https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_3e1a480eaa7282e9/code.py
- Command line
-
hf download hf://datasets/AIHero123/ChartM3/Stack/Stack_3e1a480eaa7282e9/code.py
-
curl -L -o code.py https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_3e1a480eaa7282e9/code.py
835 Bytes
| 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) | |
| # 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("figure.png") |