Skip to content

Instantly share code, notes, and snippets.

@niftycode niftycode/familyStatus.py
Last active Dec 10, 2016

Embed
What would you like to do?
Line graph that shows the family status of the citizens of Kiel, Germany
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Line graph of the familiy status of the citizens of Kiel, Germany.
The data is provided by the City of Kiel.
http://kiel.de/rathaus/statistik/open_data/index.php
familyStatus.py
version: 1.3
author: Bodo Schönfeld
last edited: 10/12/2016
"""
import csv
import matplotlib.pyplot as plt
# see https://tonysyu.github.io/raw_content/matplotlib-style-gallery/gallery.html
# for more styles
plt.style.use('bmh')
with open('kiel_gesetze_justiz_gemeldete_straftaten.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=';')
# create empty lists
jahr = []
ledig = []
verheiratet = []
for row in readCSV:
jahr.append(int(row[4]))
ledig.append(float(row[5]))
verheiratet.append(float(row[6]))
plt.title("Kiel - Familienstand\n1988-2014 (für 1993 liegt kein Wert vor)")
plt.xlabel("Jahr")
plt.ylabel("in Tsd.")
plt.plot(jahr, ledig, "r*-", markersize=6, linewidth=1, color='g', label="ledig")
plt.plot(jahr, verheiratet, "r*-", markersize=6, linewidth=1, color='r', label="verheiratet")
plt.legend(loc=(0.25, 0.75))
# plt.savefig('kiel_familienstatus.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.