feat: New plot for remaining weeks until target, annotation for target
This commit is contained in:
		
							parent
							
								
									c1f4b57bc0
								
							
						
					
					
						commit
						a1a4348ea1
					
				
					 1 changed files with 51 additions and 0 deletions
				
			
		
							
								
								
									
										51
									
								
								plot.py
									
										
									
									
									
								
							
							
						
						
									
										51
									
								
								plot.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -736,7 +736,9 @@ def plot_vaccination_done_days():
 | 
			
		|||
	days_remaining_daily = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['mean_vaccination_rates_daily']))
 | 
			
		||||
	days_remaining_rolling = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
 | 
			
		||||
 | 
			
		||||
	ax.set_xlim(start_of_reporting_date, today)
 | 
			
		||||
	ax.set_ylim(0, 2500)
 | 
			
		||||
	ax.axhline(days_until_target, label='Impfziel Ende Sommer')
 | 
			
		||||
 | 
			
		||||
	ax.plot(dates, days_remaining_daily, label='Durchschnitt Gesamt', linewidth=0.5)
 | 
			
		||||
	ax.plot(dates, days_remaining_rolling, label='Durchschnitt 7 Tage', linewidth=2)
 | 
			
		||||
| 
						 | 
				
			
			@ -757,6 +759,49 @@ def plot_vaccination_done_days():
 | 
			
		|||
 | 
			
		||||
plot_vaccination_done_days()
 | 
			
		||||
 | 
			
		||||
def plot_vaccination_done_weeks():
 | 
			
		||||
 | 
			
		||||
	plot_name = 'vaccination_done_weeks'
 | 
			
		||||
	if not check_recreate_plot(plot_name):
 | 
			
		||||
		return
 | 
			
		||||
 | 
			
		||||
	fig, ax = plt.subplots(1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	plt.title(
 | 
			
		||||
		'Lin. Extrapolation der Erstimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Anzahl Wochen, Gesamt und 7 Tage)\n'
 | 
			
		||||
		'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
 | 
			
		||||
			print_stand, print_today
 | 
			
		||||
		)
 | 
			
		||||
	)
 | 
			
		||||
	d = data_first_vaccination
 | 
			
		||||
 | 
			
		||||
	weeks_remaining_daily = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['mean_vaccination_rates_daily'])) / 7
 | 
			
		||||
	weeks_remaining_rolling = np.ceil((einwohner_deutschland * 0.7 - d['cumulative']) / (d['vaccination_rates_daily_rolling_average'])) / 7
 | 
			
		||||
 | 
			
		||||
	ax.set_xlim(datetime.datetime(2021, 3, 1), today)
 | 
			
		||||
	ax.set_ylim(0, 52)
 | 
			
		||||
	ax.axhline(days_until_target / 7, label='Impfziel Ende Sommer')
 | 
			
		||||
 | 
			
		||||
	ax.plot(dates, weeks_remaining_daily, label='Durchschnitt Gesamt', linewidth=0.5)
 | 
			
		||||
	ax.plot(dates, weeks_remaining_rolling, label='Durchschnitt 7 Tage', linewidth=2)
 | 
			
		||||
 | 
			
		||||
	ax.grid(True)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	ax.legend(loc='upper right')
 | 
			
		||||
	ax.get_yaxis().get_major_formatter().set_scientific(False)
 | 
			
		||||
 | 
			
		||||
	ax.set_xlabel('Datum')
 | 
			
		||||
	ax.set_ylabel('Wochen, bis 70 % erreicht sind')
 | 
			
		||||
 | 
			
		||||
	add_annotations(ax)
 | 
			
		||||
 | 
			
		||||
	save_plot(plot_name)
 | 
			
		||||
	plt.close()
 | 
			
		||||
 | 
			
		||||
plot_vaccination_done_weeks()
 | 
			
		||||
 | 
			
		||||
def plot_vaccination_done_dates():
 | 
			
		||||
 | 
			
		||||
	plot_name = 'vaccination_done_dates'
 | 
			
		||||
| 
						 | 
				
			
			@ -788,7 +833,9 @@ def plot_vaccination_done_dates():
 | 
			
		|||
 | 
			
		||||
	#print(dates_rolling)
 | 
			
		||||
 | 
			
		||||
	ax.set_xlim(start_of_reporting_date, today)
 | 
			
		||||
	ax.set_ylim(today, today + datetime.timedelta(int(np.max(days_remaining_rolling) * 1.05)))
 | 
			
		||||
	ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer')
 | 
			
		||||
 | 
			
		||||
	ax.plot(dates, dates_daily, label='Durchschnitt Gesamt', linewidth=0.5)
 | 
			
		||||
	ax.plot(dates[6:], dates_rolling, label='Durchschnitt 7 Tage', linewidth=2)
 | 
			
		||||
| 
						 | 
				
			
			@ -885,6 +932,10 @@ def render_dashboard():
 | 
			
		|||
				'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Anzahl Tage, Gesamt und 7 Tage)'
 | 
			
		||||
			},{
 | 
			
		||||
				'index': 10,
 | 
			
		||||
				'filename': 'vaccination_done_weeks',
 | 
			
		||||
				'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Anzahl Wochen, Gesamt und 7 Tage)'
 | 
			
		||||
			},{
 | 
			
		||||
				'index': 11,
 | 
			
		||||
				'filename': 'vaccination_done_dates',
 | 
			
		||||
				'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)'
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue