Programme für Diagrammtypen: Säule, gestapelte Säulen
Linien, gestapelte Balken, Torte
This commit is contained in:
43
teil23/vornamen_torte.py
Executable file
43
teil23/vornamen_torte.py
Executable file
@@ -0,0 +1,43 @@
|
||||
#! ./bin/python
|
||||
#encondig: utf-8
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import logging
|
||||
from vornamen_reader import read_vornamen
|
||||
|
||||
logging.basicConfig( format='%(asctime)-15s [%(levelname)s] %(funcName)s: %(message)s', level=logging.INFO)
|
||||
|
||||
def plot_geschlecht(vornamen):
|
||||
|
||||
bez= ['Mädchen', 'Jungs','divers']
|
||||
geburten = [vornamen['mädchen'], vornamen['jungs'],vornamen['divers']]
|
||||
|
||||
logging.info(f'geburten={geburten}')
|
||||
|
||||
proz_maedels = round(vornamen['mädchen'] / vornamen['gesamt'] *100,2)
|
||||
proz_jungs = round(vornamen['jungs'] / vornamen['gesamt'] *100,2)
|
||||
proz_divers = round(vornamen['divers'] / vornamen['gesamt'] *100,2)
|
||||
|
||||
farben = ['red','blue','green']
|
||||
sizes= [proz_maedels,proz_jungs,proz_divers]
|
||||
|
||||
logging.info(f'sizes={sizes}')
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
ax.pie(sizes,explode=(0,0,0), labels=bez,autopct='%1.1f%%',shadow=True,startangle=90)
|
||||
ax.axis('equal')
|
||||
|
||||
plt.show()
|
||||
|
||||
if __name__ == '__main__':
|
||||
vornamen = read_vornamen('./Vornamen_Wuppertal_2020.csv')
|
||||
|
||||
jungs= vornamen['jungs']
|
||||
maedels = vornamen['mädchen']
|
||||
divers = vornamen['divers']
|
||||
|
||||
|
||||
plot_geschlecht(vornamen)
|
||||
|
||||
|
Reference in New Issue
Block a user