Adjust image

master
Misha 2023-03-01 18:55:26 +01:00
parent d53c252455
commit a8974f894f
3 changed files with 46530 additions and 6 deletions

46524
data/owid-co2-data.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@ -38,11 +38,11 @@ scope = 21
df = df.tail(scope)
# Create a horizontal barplot of year against cumulative_co2
ax = df.plot.barh(x='year', y='share_gen', color = 'gray')
ax = df.plot.barh(x='year', y='share_gen', color = 'silver', width=0.8, linestyle = "")
# Add rasters to the plot
ax.grid(axis='x', linestyle='--', alpha=0.5)
ax.grid(axis='y', linestyle='--', alpha=0.5)
ax.grid(axis='x', linestyle='-', alpha=0.5, color = 'white', zorder=1)
ax.grid(axis='y', linestyle='-', alpha=0.5, color = 'white', zorder=1)
# Add names to axes
ax.set_ylabel('year of birth')
@ -63,12 +63,12 @@ year_born = 1987
# Rounding off to five year
diff_year = 5 * round((df['year'].iloc[-1]-year_born)/5)
generation=-(int((diff_year/5)+1))
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
props = dict(boxstyle='round', facecolor='lightgreen', alpha=0.5)
ax.text(0.63, 0.97, "If you were born in %s,\n%s%% of the total amount \nof CO2 that has been \nemitted since 1750, has \nbeen emitted in your \nlifetime." % (df['year'].iloc[generation], int(df['share_gen'].iloc[generation])), transform=ax.transAxes, fontsize=10,
verticalalignment='top', bbox=props)
ax.patches[generation].set_facecolor('#aa3333')
plt.vlines(x = df['share_gen'].iloc[generation], ymin = -1, ymax = scope+generation, color='#aa3333')
ax.patches[generation].set_facecolor('lightcoral')
plt.vlines(x = df['share_gen'].iloc[generation], ymin = -1, ymax = scope+generation, color='lightcoral')
plt.annotate('https://codeberg.org/mishathings/share_CO2_generation', (0,0), (-55,-30), fontsize=6,
xycoords='axes fraction', textcoords='offset points', va='top')

BIN
output.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 KiB