File:Co2 by fuel pie chart.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (SVG file, nominally 540 × 540 pixels, file size: 20 KB)

Captions

Captions

Fossil fuel greenhouse gas emissions by a country in a year by fuel in megatons.

Summary

[edit]
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
 
The SVG code is valid.
 
This plot was created with Matplotlib.
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

[edit]
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.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current10:55, 27 February 2019Thumbnail for version as of 10:55, 27 February 2019540 × 540 (20 KB)Chidgk1 (talk | contribs)example file must not be identical real one
08:34, 27 February 2019Thumbnail for version as of 08:34, 27 February 2019540 × 540 (20 KB)Chidgk1 (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

Metadata