Alle Dateien aus dem Pythonkurs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

#! ./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)