File:Co2 by fuel pie chart.svg

Summary

Description
English: To create similar for another country or year get the data on "CO2 Emissions by Energy Source" from

www.iea.org//statistics/ and replace the values in the code below.

Install Python and Matplot on your computer, amend the output file name for your country, run the program and upload to a new commons file.
Date
Source Own work
Author Chidgk1
SVG development
InfoField
Source code
InfoField

Python code

import matplotlib.pyplot as plt
import numpy as np

plt.rcdefaults()
plt.style.use('ggplot')
plt.rcParams['font.size'] = 19
plt.rcParams['patch.edgecolor'] = 'black'
plt.rcParams['lines.linewidth'] = 1
plt.figure(figsize=[6,6])

labels = ['Coal', 'Oil', 'Gas']
values = [155.7,112.27,87.3]
colours = ['#754513','darkgrey','khaki']
angle = 90

def func(pct, allvals):
    absolute = int(round(pct/100.*np.sum(allvals)))
    return "{:.2n}%\n({:d} mt)".format(pct, absolute)

patches, texts, autotexts = plt.pie(values, colors=colours, autopct=lambda pct: func(pct, values), pctdistance=0.6, labels=labels, labeldistance=1.1, shadow=False, startangle=angle)

for at in autotexts:
    at.set_fontsize(16.21)

plt.axis('equal')
plt.tight_layout()
plt.gca().set_position([0, 0, 1, 1])
plt.gcf().subplots_adjust(bottom=0.15)

plt.savefig('co2_by_fuel_pie_chart.svg')

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#Co2%20by%20fuel%20pie%20chart.svg
Category:Self-published work Category:Greenhouse gas emissions by sector Category:Fossil fuels Category:English-language SVG pie charts
Category:CC-BY-SA-4.0 Category:English-language SVG pie charts Category:Fossil fuels Category:Greenhouse gas emissions by sector Category:Self-published work Category:Valid SVG created with Matplotlib code