| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import pandas as pd
- import matplotlib.pyplot as plt
- import matplotlib.dates as mdates
- from matplotlib import rcParams
- FONT_COLOR = '#595959'
- SUSCEPTIBLE = '#6399f7'
- INFECTIOUS = '#f56262'
- REMOVED = '#83eb5e'
- # rki data
- rki_data_path = 'datasets/COVID-19-Todesfaelle_in_Deutschland/COVID-19-Todesfaelle_Deutschland.csv'
- rki_data = pd.read_csv(rki_data_path)
- rki_data['Berichtsdatum'] = pd.to_datetime(rki_data['Berichtsdatum'], errors='coerce')
- specific_dates = rki_data[rki_data['Berichtsdatum'].dt.is_quarter_start]['Berichtsdatum']
- rcParams['font.family'] = 'Comfortaa'
- rcParams['font.size'] = 12
- rcParams['text.color'] = FONT_COLOR
- rcParams['axes.labelcolor'] = FONT_COLOR
- rcParams['xtick.color'] = FONT_COLOR
- rcParams['ytick.color'] = FONT_COLOR
- slide3 = plt.figure(figsize=(12,6))
- ax = slide3.add_subplot(111, facecolor='#dddddd', axisbelow=True)
- ax.set_facecolor('xkcd:white')
- ax.plot(rki_data['Berichtsdatum'], rki_data['Faelle_gesamt'], label='infections', c=INFECTIOUS, lw=3)
- ax.plot(rki_data['Berichtsdatum'], rki_data['Todesfaelle_gesamt'], label='death cases', c=REMOVED, lw=3)
- plt.yscale('log')
- plt.ylabel('amount of poeple')
- plt.xlabel('time')
- plt.title('Accumulated cases (RKI Data)')
- ax.yaxis.set_tick_params(length=0)
- leg = plt.legend()
- ax.yaxis.set_tick_params(length=0, which='both')
- ax.xaxis.set_tick_params(length=0, which='both')
- ax.grid(which='major', c='black', lw=0.2, ls='-')
- for spine in ('top', 'right', 'bottom', 'left'):
- ax.spines[spine].set_visible(False)
- plt.gca().set_xticks(specific_dates)
- plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%b %Y'))
- plt.gcf().autofmt_xdate(rotation=45, ha='center')
- slide3.savefig('visualizations/slide3.png', transparent=True)
|