Download Stack/Stack_69715896090fc0ed/code_edit.py from AIHero123/ChartM3: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_69715896090fc0ed/code_edit.py
- Command line
-
hf download hf://datasets/AIHero123/ChartM3/Stack/Stack_69715896090fc0ed/code_edit.py
-
curl -L -o code_edit.py https://huggingface.co/datasets/AIHero123/ChartM3/resolve/main/Stack/Stack_69715896090fc0ed/code_edit.py
1.27 kB
| import matplotlib.pyplot as plt | |
| import random | |
| from matplotlib.patheffects import SimplePatchShadow, Normal | |
| # Define the distance in kilometers | |
| distance = [0, 10, 20, 30, 40, 50, 60] | |
| # Define the height of ash dispersed in meters for each eruption | |
| eruption1 = [200, 150, 120, 80, 40, 20, 10] | |
| eruption2 = [250, 200, 180, 140, 100, 50, 30] | |
| eruption3 = [180, 160, 130, 100, 70, 40, 20] | |
| # Create a figure and a set of subplots | |
| fig, ax = plt.subplots() | |
| # Create a stack plot for the ash dispersed data | |
| ax.stackplot(distance, eruption1, eruption2, eruption3, labels=['Eruption 1', 'Eruption 2', 'Eruption 3']) | |
| # Apply modifications to the target object | |
| for i, area in enumerate(ax.collections): | |
| if i == 1: # Target Eruption 2 | |
| area.set_zorder(1) | |
| shadow_color = 'gold' | |
| area.set_path_effects([SimplePatchShadow(offset=(3.40, 3.06), shadow_rgbFace=shadow_color), Normal()]) | |
| # Set the title for the stack plot | |
| ax.set_title('Ash Dispersion from Explosive Volcanic Eruptions') | |
| # Set the label for X-axis and Y-axis | |
| ax.set_xlabel('Distance from the Volcano (km)') | |
| ax.set_ylabel('Height of Ash Dispersion (m)') | |
| # Create a legend for the stack plot | |
| ax.legend(loc='upper right') | |
| # Show the stack plot | |
| plt.tight_layout() | |
| plt.savefig("Edit_figure.png") |