Download Stack/Stack_363b2eb1a050329e/code.py from AIHero123/ChartM3: direct link, hf CLI and curl.
- Browser
- Download file 789 Bytes
-
https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_363b2eb1a050329e/code.py
- Command line
-
hf download hf://datasets/AIHero123/ChartM3/Stack/Stack_363b2eb1a050329e/code.py
-
curl -L -o code.py https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_363b2eb1a050329e/code.py
789 Bytes
| import matplotlib.pyplot as plt | |
| years = ['Year 1', 'Year 2', 'Year 3', 'Year 4', 'Year 5'] | |
| # Percentages of market shares | |
| apple = [40, 35, 30, 28, 25] | |
| samsung = [30, 28, 25, 24, 23] | |
| xiaomi = [15, 20, 22, 20, 18] | |
| huawei = [10, 12, 13, 15, 17] | |
| others = [5, 5, 10, 13, 17] | |
| # Stacking each brand's market share on top of the other | |
| plt.stackplot(years, apple, samsung, xiaomi, huawei, others, | |
| colors=['green','blue','orange','red','gray'], | |
| labels=['Apple', 'Samsung', 'Xiaomi', 'Huawei', 'Others']) | |
| # Title and labels | |
| plt.title('Market Share of Top-Selling Smartphone Brands Over Five Years') | |
| plt.xlabel('Year') | |
| plt.ylabel('Market Share (%)') | |
| # Positioning the legend | |
| plt.legend(loc='upper left') | |
| # Show the plot | |
| plt.tight_layout() | |
| plt.savefig("figure.png") |