Download Stack/Stack_344ed9a8e546ab2b/code_edit.py from AIHero123/ChartM3: direct link, hf CLI and curl.
- Browser
- Download file 824 Bytes
-
https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_344ed9a8e546ab2b/code_edit.py
- Command line
-
hf download hf://datasets/AIHero123/ChartM3/Stack/Stack_344ed9a8e546ab2b/code_edit.py
-
curl -L -o code_edit.py https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_344ed9a8e546ab2b/code_edit.py
824 Bytes
| import matplotlib.pyplot as plt | |
| # Years of the journey | |
| years = ['Year 1', 'Year 2', 'Year 3', 'Year 4', 'Year 5'] | |
| # Distances from Earth | |
| alpha_centauri = [4.3, 4.4, 4.5, 4.5, 4.6] | |
| sirius = [8.6, 8.5, 8.4, 8.3, 8.2] | |
| betelgeuse = [642, 640, 638, 636, 634] | |
| polaris = [443, 442, 441, 441, 440] | |
| plt.stackplot(years, alpha_centauri, sirius, betelgeuse, polaris, colors=['red', 'blue', 'green', 'purple']) | |
| # Add legend | |
| plt.legend(['Alpha Centauri', 'Sirius', 'Betelgeuse', 'Polaris'], loc='upper left') | |
| plt.title("Journey of a Spacecraft to Various Stars") | |
| plt.xlabel("Years") | |
| plt.ylabel("Distance from Earth (in light-years)") | |
| for i, area in enumerate(plt.gca().collections): | |
| if i == 2: # Betelgeuse's stack | |
| area.set_snap(False) | |
| area.set_visible(False) | |
| plt.tight_layout() | |
| plt.savefig("Edit_figure.png") |