Jump to content

File:Wind power installed capacity and generation in Denmark.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 614 × 461 pixels, file size: 40 KB)

Render this image in .
This image should always reflect the most recent version. Feel free to update it when needed.

Note: 
To do this, add current data to the source code and execute the Python program. This creates a (local) SVG file that can be uploaded to Commons.

Summary

Description
Deutsch: Windenergie in Dänemark
English: This plot shows a Bar Chart of the installed Wind power capacity and generation in Denmark. You find the Python code to regenerate this SVG below. Please update the data in the future ! Data from Windenergie_in_Dänemark and Énergie_éolienne_au_Danemark
Date
Source Own work
Author MTheiler
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

Source code
from copy import deepcopy
from lxml import etree
import matplotlib.pyplot as plt
import numpy as np

# Wind power installed capacity and generation in Denmark
# multilingual
# Production data from  https://fr.wikipedia.org/wiki/Énergie_éolienne_au_Danemark
# installed  data from  https://de.wikipedia.org/wiki/Windenergie_in_Dänemark

data=[
# show_X, year, installed (MW), Production (GWh)
['x',2005 ,3127 , 6614 ] ,
[' ',2006 ,3136 , 6108 ] ,
[' ',2007 ,3124 , 7171 ] ,
[' ',2008 ,3158 , 6928 ] ,
[' ',2009 ,3468 , 6721 ] ,
['x',2010 ,3801 , 7809 ] ,
[' ',2011 ,3956 , 9774 ] ,
[' ',2012 ,4161 ,10270 ] ,
[' ',2013 ,4807 ,11123 ] ,
[' ',2014 ,4883 ,13079 ] ,
['x',2015 ,5064 ,14133 ] ,
[' ',2016 ,5227 ,12782 ] ,
[' ',2017 ,5476 ,14780 ] ,
[' ',2018 ,5751 ,13902 ] ,
[' ',2019 ,6128 ,16150 ] ,
['x',2020 ,6180 ,16330 ] ,
[' ',2021 ,7014 ,16054 ] ,
[' ',2022 ,7282 ,18873 ] ,
['x',2023 ,7562 ,19540 ] 
]
# please update in future.

show_yesno = np.array([row[0] for row in data])
all_years  = np.array([row[1] for row in data])
bar_labels = []

# show axis-labels only the years marked with 'x'
for i, yesNo in enumerate(show_yesno):
    if (yesNo == 'x'):
        bar_labels.append(all_years[i])
    else:
        bar_labels.append("")
        
data_installed      = np.array([row[2] for row in data])  # installed
data_generated      = np.array([row[3] for row in data])  # generated
# percent =  np.array([row[4] for row in data])   future use

fig = plt.figure()
ax1 = plt.gca()
ax2 = ax1.twinx()

plt.xticks(range(len(bar_labels)), bar_labels  )

plt.rcParams.update({'text.usetex':False, "svg.fonttype":"none", "font.size":13})

filename = "Wind_power_installed_capacity_and_generation_in_Denmark.svg"
delta= "  "+ str(min(all_years)) + "-" + str(max(all_years))

labels = {'title': {"en":"Wind power in Denmark " + delta,
                    "de":"Windenergie in Dänemark" + delta,
                    "fr":"Énergie éolienne au Danemark" + delta,
                    "it":"Energia eolica in Danimarca" + delta,
                    "pl":"Energetyka wiatrowa w Danii" + delta,
                    "pt":"Energia eólica na Dinamarca" + delta,
                    "tr":"Danimarka'da rüzgâr enerjisi" + delta,
                    "es":"Energía eólica en Dinamarca" + delta},
          "installed": {"en":"installed capacity (MW)",
                        "de":"installierte Leistung (MW)",
                        "es":"capacidad instalada (MW)",
                        "it":"Capacità installata (MW)",
                        "pl":"Moc zainstalowana (MW)",
                        "pt":"capacidade instalada (MW)",
                        "tr":"Kurulu kapasite (MW)" ,
                        "fr":"Puissance installée (MW)"},
          "generation": {"en":"generation (GWh)             ",
                         "de":"erzeugt (GWh)",
                         "es":"producción (GWh)",
                         "it":"Produzione (GWh)",
                         "pl":"Produkcja energii (GWh)"  ,
                         "pt":"produção energética (GWh)",
                         "tr":"Elektrik üretimi (GWh)" ,
                         "fr":"Production (GWh)"}
            }

width =0.3
ax1.bar(np.arange(len(data_installed))- width/2,  data_installed, width=width)
ax2.bar([0], [0],  width=width, label=labels["installed"]["en"]  )
ax2.bar(np.arange(len(data_generated))+ width/2, data_generated, width=width, color='red', label=labels["generation"]["en"])

plt.title(labels["title"]["en"])
ax1.set_ylabel(labels["installed"]["en"])
ax2.set_ylabel(labels["generation"]["en"])

ax1.set_xlabel("Source: https://de.wikipedia.org/wiki/Windenergie_in_Dänemark \n+ https://fr.wikipedia.org/wiki/Énergie_éolienne_au_Danemark ", fontsize='xx-small')

plt.legend(loc='upper left', borderaxespad=1.5)
plt.tight_layout()

plt.savefig(filename)
#plt.show()

# create multilingual labels with the svg switch element
with open(filename, mode="r",encoding='utf-8') as svgfile:
    svg = etree.parse(svgfile, etree.XMLParser()).getroot()
for label, values in labels.items():
    for el in svg.findall(".//{" + svg.nsmap[None] + "}text"):
        if el.text == values["en"]:
            switch = etree.SubElement(el.getparent(), "switch")
            for lang, text in values.items():
                el2 = deepcopy(el)
                el2.set("systemLanguage", lang)
                el2.text = text
                switch.append(el2)
            switch.append(el)
with open(filename, mode='w', encoding='utf-8') as svgfile:
    svgfile.write(etree.tostring(svg, pretty_print=True, encoding="unicode"))
Click at right to show/hide Durchführung eines Updates (Deutsch)

Dieses Chart wurde mit der Progammiersprache Python und der Bibliothek Matplotlib erstellt. Das dargestellte Diagramm ist mehrsprachig; die Beschriftungen des Diagramms werden abhängig von der Sprache des Wikis angezeigt. Diese Mehrsprachigkeit ist mit Hilfe des SVG switch-Elementes realisiert. Es sind folgende Motivationen für ein Update denkbar: (a) Übersetzung in eine weitere Sprache. (b) Fortschreibung der Daten für weitere Jahre. Hierzu ist jeweils im Python-Programmcode die entsprechende Erweiterung vorzunehmen.

Durchführung des Updates

(1) Den Python-Programmcode dieses Diagrammes kopieren und lokal in einer Datei mit der Endung .py speichern. Falls lokal diese Programmiersprache installiert ist, dann läßt sich dieses Programm mit dem Befehl: python <lokaler dateiname>.py ausführen. Bei der Ausführung wird lokal eine neue .svg Datei erzeugt.

(2) Fortschreibung der im Programmcode enthaltenen Daten, z.B. für das nächste Jahr. Dies kann in einem Texteditor wie z.B. Geany oder in einer IDE wie z.B. Thonny geschehen.

(3) Ausführung des Python-Programmes und hierdurch Erzeugung des SVG-Bildes. Dieses SVG-Bild ist lokal darstellbar.

(4) Upload des SVGs nach Commons

(5) Update des erweiterten Sourcecodes auf Commons.

Wenn auf dem eigenen Rechner die Programmiersprache Python nicht zur Verfügung steht, dann können die Schritte (2) und (3) auch auf wikimedia/PAWS durchgeführt werden.


Click at right to show/hide How to do an Update (English)

This chart was created with the programming language Python and the library Matplotlib. The displayed diagram is multilingual; the labels of the diagram are displayed depending on the language of the wiki. This multilingualism is realized with the help of the SVG switch element. The following motivations for an update are conceivable: (a) Translation into another language. (b) Updating the data for further years. For this purpose, the corresponding extension must be made in the Python program code.

Performing the update

(1) Copy the Python program code of this diagram and save it locally in a file with the extension .py. If this programming language is installed locally, this program can be executed with the command: python <local filename>.py. A new .svg file is created locally during execution.

(2) Update the data contained in the program code, e.g. for the next year. This can be done in a text editor such as Geany or in an IDE such as Thonny.

(3) Execution of the Python program and thereby generation of the SVG image. This SVG image can be displayed locally.

(4) Upload the SVG to Commons

(5) Update the extended source code on Commons.

If the Python programming language is not available on your own computer, then steps (2) and (3) can also be carried out on wikimedia/PAWS.


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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

15 February 2025

File history

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

Date/TimeThumbnailDimensionsUserComment
current17:22, 15 February 2025Thumbnail for version as of 17:22, 15 February 2025614 × 461 (40 KB)MTheilerbetter translation
16:45, 15 February 2025Thumbnail for version as of 16:45, 15 February 2025614 × 461 (40 KB)MTheilerUploaded own work with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

Metadata