def total_death_chart(root): global fig, ax total_death_date = [ i.replace('\"', '') for i in list(set(re.findall(r'categories:.*', main[33])))[0].replace( 'categories: [', '').replace(']', '').replace('}', '').replace( ' ', '').split(',') if i != '' ] total_death = [ int(i) for i in data[10][0].replace('data: [', '').replace(']', '').replace( '}', '').replace(' ', '').split(',') if i != '' ] fig, ax = plt.subplots() plt.xticks(np.arange(0, len(total_death_date), 5.0)) def format_func(value, tick_number): return ShortScale(int(value)) ax.yaxis.set_major_formatter(plt.FuncFormatter(format_func)) fig.set_size_inches(13, 6) line_info, datax = plot_line(total_death_date, total_death, 'white', 'Deaths', ax, fig, 'Total Deaths') plt.xticks(rotation=45) canvas = FigureCanvasTkAgg(fig, master=root) plot_widget = canvas.get_tk_widget() fig.canvas.mpl_connect( "motion_notify_event", lambda event: hover(event, line_info, fig, ax, datax)) return plot_widget
def active_cases_chart(root): active_cases_date = [ i.replace('\"', '') for i in list(set(re.findall(r'categories:.*', main[25])))[0].replace( 'categories: [', '').replace(']', '').replace('}', '').replace( ' ', '').split(',') if i != '' ] active_cases = [ int(i) for i in data[3][0].replace('data: [', '').replace(']', '').replace( '}', '').replace(' ', '').split(',') if i != '' ] fig, ax = plt.subplots() x_ticks = np.arange(0, len(active_cases_date), 6) plt.xticks(x_ticks) def format_func(value, tick_number): return ShortScale(int(value)) ax.yaxis.set_major_formatter(plt.FuncFormatter(format_func)) fig.set_size_inches(13, 6) line_info, datax = plot_line(active_cases_date, active_cases, 'white', 'Currently Infected', ax, fig, 'Active Cases') plt.xticks(rotation=45) canvas = FigureCanvasTkAgg(fig, master=root) plot_widget = canvas.get_tk_widget() fig.canvas.mpl_connect( "motion_notify_event", lambda event: hover(event, line_info, fig, ax, datax)) return plot_widget
def infected_vs_recovered_chart(root): date = [ i.replace('\"', '') for i in list(set(re.findall(r'categories:.*', main[28])))[0].replace( 'categories: [', '').replace(']', '').replace('}', '').replace( ' ', '').split(',') if i != '' ] daily_cases = [ i for i in data[2][0].replace('data: [', '').replace(']', '').replace( '}', '').replace(' ', '').split(',') if i != '' ] daily_cases = [ 0 if daily_cases[i] == 'null' else int(daily_cases[i]) for i in range(len(daily_cases)) ] daily_cured = [ i for i in data[5][0].replace('data: [', '').replace(']', '').replace( '}', '').replace(' ', '').split(',') if i != '' ] daily_cured = [ 0 if daily_cured[i] == 'null' else int(daily_cured[i]) for i in range(len(daily_cured)) ] fig, ax = plt.subplots() x_ticks = np.arange(0, len(date), 5) plt.xticks(x_ticks) def format_func(value, tick_number): return ShortScale(int(value)) ax.yaxis.set_major_formatter(plt.FuncFormatter(format_func)) fig.set_size_inches(13, 6) line_info1, line_info2, datax = plot_double_line( date, daily_cured, date, daily_cases, '#baffba', '#ffbaba', 'New Recoviries', 'New Infected', ax, fig, 'New Cases vs. New Recoveries') plt.xticks(rotation=45) canvas = FigureCanvasTkAgg(fig, master=root) plot_widget = canvas.get_tk_widget() fig.canvas.mpl_connect( "motion_notify_event", lambda event: hover(event, line_info1, fig, ax, datax)) fig.canvas.mpl_connect( "motion_notify_event", lambda event: hover(event, line_info2, fig, ax, datax)) return plot_widget
def outcome_of_total_close_cases(root): date = [i.replace('\"', '') for i in list(set(re.findall(r'categories:.*', main[32])))[0].replace('categories: [', '').replace(']', '').replace('}', '').replace(' ', '').split(',') if i != ''] death_rate = [i for i in data[9][0].replace('data: [', '').replace(']', '').replace('}', '').replace(' ', '').split(',') if i != ''] death_rate = [0 if death_rate[i] == 'null' else float(death_rate[i]) for i in range(len(death_rate))] recovery_rate = [i for i in data[9][1].replace('data: [', '').replace(']', '').replace('}', '').replace(' ', '').split(',') if i != ''] recovery_rate = [0 if recovery_rate[i] == 'null' else float(recovery_rate[i]) for i in range(len(recovery_rate))] fig, ax = plt.subplots() x_ticks = np.arange(0, len(date), 10) plt.xticks(x_ticks) fig.set_size_inches(13, 6) line_info1, line_info2, datax = plot_double_line(date, death_rate, date, recovery_rate, '#ffbaba', '#baffba', 'Death Rate', 'Recovery Rate', ax, fig, 'Outcome of total closed cases (recovery rate vs death rate)') plt.xticks(rotation=45) canvas = FigureCanvasTkAgg(fig, master=root) plot_widget = canvas.get_tk_widget() fig.canvas.mpl_connect("motion_notify_event", lambda event: hover(event, line_info1, fig, ax, datax)) fig.canvas.mpl_connect("motion_notify_event", lambda event: hover(event, line_info2, fig, ax, datax)) return plot_widget
def total_serious_and_critical_cases(root): total_serious_and_critical_cases_date = [i.replace('\"', '') for i in list(set(re.findall(r'categories:.*', main[31])))[0].replace('categories: [', '').replace(']', '').replace('}', '').replace(' ', '').split(',') if i != ''] total_serious_and_critical_cases = [i for i in data[7][0].replace('data: [', '').replace(']', '').replace('}', '').replace(' ', '').split(',') if i != ''] total_serious_and_critical_cases = [0 if total_serious_and_critical_cases[i] == 'null' else int(total_serious_and_critical_cases[i]) for i in range(len(total_serious_and_critical_cases))] fig, ax = plt.subplots() x_ticks = np.arange(0, len(total_serious_and_critical_cases_date), 10) plt.xticks(x_ticks) def format_func(value, tick_number): return ShortScale(int(value)) ax.yaxis.set_major_formatter(plt.FuncFormatter(format_func)) fig.set_size_inches(13, 6) line_info, datax = plot_line(total_serious_and_critical_cases_date, total_serious_and_critical_cases, 'white', 'Serious and Critical Cases', ax, fig, 'Total Serious and Critical Cases') plt.xticks(rotation=45) canvas = FigureCanvasTkAgg(fig, master=root) plot_widget = canvas.get_tk_widget() fig.canvas.mpl_connect("motion_notify_event", lambda event: hover(event, line_info, fig, ax, datax)) return plot_widget