Skip to content

Instantly share code, notes, and snippets.

@niftycode
Last active December 10, 2016 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niftycode/30f2c0e1f68bcc70f65ba61947f2c67b to your computer and use it in GitHub Desktop.
Save niftycode/30f2c0e1f68bcc70f65ba61947f2c67b to your computer and use it in GitHub Desktop.
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