diff --git a/img/comparison.png b/img/comparison.png index e3e1e90..16840bb 100644 Binary files a/img/comparison.png and b/img/comparison.png differ diff --git a/src/comparison.py b/src/comparison.py index 9d0cc49..a5fe3ec 100644 --- a/src/comparison.py +++ b/src/comparison.py @@ -3,6 +3,7 @@ import numpy as np from collections import defaultdict import sys +import datetime def fips_to_name(FIPS): map = defaultdict(lambda: FIPS) @@ -14,20 +15,25 @@ def fips_to_name(FIPS): return map[FIPS] def comparison(FIPS_1='44003', FIPS_2='01125'): - months = { - 'May':'05-31-2021', - 'June':'06-30-2021', - 'July':'07-31-2021', - 'August':'08-31-2021', - 'September':'09-30-2021', - 'October':'10-31-2021', - 'November':'11-30-2021' - } + months = pd.read_csv("months.csv") + dates = months.date.to_list() + #x = [0, 1, 2, 3, 4, 5, 6] + #labels = ['May', 'June', 'July', 'August', 'September', 'October', 'November'] + x = [] + labels = [] file_list = [] - for month, csv_date in months.items(): - df = pd.read_csv('data/Merge/vaccinations-and-deaths-' + csv_date +'.csv', converters={'FIPS' : str}) + i = 0 + #To update x, y labels of county-view graph from dates in csv + for date in dates: + datetime_object = datetime.datetime.strptime(date, "%m-%d-%Y") + month_Name = datetime_object.strftime("%B") + month_year= datetime_object.strftime("%b")+"-"+datetime_object.strftime("%y") + labels.append(month_year) + x.append(i) + i= i+1 + df = pd.read_csv('data/Merge/vaccinations-and-deaths-' + date +'.csv', converters={'FIPS' : str}) df['Deaths_Per_1e5'] = df['Deaths'] / df['Census2019_18PlusPop'] * 1e5 - df['Month'] = month + df['Month'] = month_Name file_list.append(df) merged_df = pd.concat(file_list) cleaned_df = merged_df[merged_df['FIPS'].str.contains(FIPS_1+"|"+FIPS_2)] @@ -47,13 +53,15 @@ def comparison(FIPS_1='44003', FIPS_2='01125'): FIPS_2_death = FIPS_2_death['Deaths_Per_1e5'] fig,ax1 = plt.subplots() - x = [0, 1, 2, 3, 4, 5, 6] - labels = ['May', 'June', 'July', 'August', 'September', 'October', 'November'] + + plt.tick_params(axis='x', rotation=30 ,direction='out', length=len(x)) + plt.figure(figsize=(len(x), 100)) x = np.arange(len(labels)) - width = 0.35 + width = 0.35 ax1.set_xticks(x, labels) ax1.set_ylim(0, 100) - ax1.set_xlim(0,6) + ax1.set_xlim(-1,len(x)) + ax1.set_title('18+ Vaccination Rates and Deaths in '+FIPS_1_name+" and "+FIPS_2_name, wrap=True) ax1.set_xlabel('Month 2021') ax1.set_ylabel('Percent Vaccinated') diff --git a/src/scatters.py b/src/scatters.py index 21ba4b2..1276db4 100644 --- a/src/scatters.py +++ b/src/scatters.py @@ -6,6 +6,7 @@ import matplotlib.pyplot as plt import sys import numpy as np +import datetime def scatter(month): df = pd.read_csv('data/Merge/vaccinations-and-deaths-'+month+'.csv', converters={'FIPS' : str}) @@ -16,13 +17,17 @@ def scatter(month): x = df[xlabel] y = df[ylabel] area = df['Census2019_18PlusPop'] / 1e6 #population in millions + + #To display date in interantional date format on the animation + IDF_date = date1 = datetime.strptime(month, '%m-%d-%Y').strftime('%Y-%m-%d') + fig, ax = plt.subplots() ax.set_xlabel("Percent of Population (+18) Considered Fully Vaccinated") ax.set_ylabel("Deaths per 100K") ax.set_xlim(0,100) ax.set_ylim(0,400) #[KR] changed from 500 limit to 400 limit - ax.set_title("Vaccine Effectiveness Snapshot as of: "+ month) + ax.set_title("Vaccine Effectiveness Snapshot as of: "+ IDF_date) fig.set_size_inches(8,6) ax.spines['top'].set_visible(False) #[MR] Removes top spine ax.spines['right'].set_visible(False) #[MR] Removes right spine