-
Notifications
You must be signed in to change notification settings - Fork 0
/
MobilityAndCasesPlots.py
37 lines (26 loc) · 1.23 KB
/
MobilityAndCasesPlots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Run 4th
# Plots average mobility with infection rate (aka new cases per day)
from matplotlib import pyplot as plt
import pandas as pd
mobility_path = "C:/Users/justi/Documents/Covid research/Mobility Data/Florida Mobility Data 12-14.xlsx"
infection_path = "C:/Users/justi/PycharmProjects/COVID-19/Scripts after 12-14/Infection_Rate_Florida_All.csv"
df_mobility = pd.read_excel(mobility_path)
df_infection_rate = pd.read_csv(infection_path)
df_mobility_dates = df_mobility['date']
df_mobility_averages = df_mobility['average_percent_change']
df_infection_dates = df_infection_rate['Date'].to_numpy()
df_infection_cases = df_infection_rate['New Cases'].to_numpy()
# subtract 2; one for indexing at 0, one for header names in the first row
df_mobility_dates = df_mobility_dates[:300].to_numpy()
df_mobility_averages = df_mobility_averages[:300].to_numpy()
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(df_mobility_dates, df_mobility_averages)
ax1.set_ylabel('Average Mobility Change From Baseline (%)')
ax2 = ax1.twinx()
ax2.plot(df_infection_dates, df_infection_cases, 'r-')
ax2.set_ylabel('New Cases Per Day', color='r')
for tl in ax2.get_yticklabels():
tl.set_color('r')
plt.tight_layout()
plt.show()