-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotdata_covid19.py
461 lines (358 loc) · 21.9 KB
/
plotdata_covid19.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# data from https://github.com/CSSEGISandData/COVID-19
import datetime
import pandas
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from plotdata_covid19_functions import *
from TimeSeries import TimeSeriesCountries, TimeSeriesStates, TimeSeriesCounties
from California_data import CaliforniaData
matplotlib.interactive(True)
#which = 'deaths'
#which = 'confirmed'
#which = 'recovered'
plot_trajectories = False
plot_death_rates = False
plot_doubling_rates = False
plot_scatter_plots = False
plot_time_shifted = False
country_list = ['France',
'Italy',
'US',
'Spain',
'Germany',
'China',
'Korea, South',
'India',
'Russia',
'United Kingdom',
'Japan',
'Australia']
state_list = ['California',
'Washington',
'Oregon',
'New York',
'New Jersey',
'Massachusetts',
'Michigan',
'Florida',
'Virginia',
'Maryland']
county_list = ['Contra Costa',
'Alameda',
'San Francisco',
'Marin',
'San Mateo',
'Santa Clara',
'Solano'
]
countries_data = {'confirmed':TimeSeriesCountries(which='confirmed'),
'deaths':TimeSeriesCountries(which='deaths')}
states_data = {'confirmed':TimeSeriesStates(which='confirmed'),
'deaths':TimeSeriesStates(which='deaths')}
counties_data = {'confirmed':TimeSeriesCounties(which='confirmed'),
'deaths':TimeSeriesCounties(which='deaths')}
#california_data = CaliforniaData()
country_populations = pandas.read_csv('country_populations.csv')
state_populations = pandas.read_csv('state_populations.csv')
county_populations = pandas.read_csv('county_populations.csv')
#import pdb
#pdb.set_trace()
def plot_finish(fig, png_name):
fig.tight_layout()
fig.subplots_adjust(bottom=.125)
fig.suptitle('data from https://github.com/CSSEGISandData/COVID-19', y=0.02)
fig.savefig(f'../../Dropbox/Public/COVID19/{png_name}')
fig.show()
def generate_colors(ncolors):
'Generate random colors'
levels = np.linspace(0., 1., ncolors)
rng = np.random.default_rng()
reds = rng.permutation(levels)
greens = rng.permutation(levels)
blues = rng.permutation(levels)
return [(reds[i], greens[i], blues[i]) for i in range(ncolors)]
####################### Countries
mincases = 200000
mindeaths = 10000
country_list_confirmed = countries_data['confirmed'].find_maxes(scale_population=True, mincases=mincases, derivative=False)
for country in ['US', 'China', 'Korea, South', 'Sweden', 'Germany']:
if country not in country_list_confirmed:
country_list_confirmed.append(country)
country_list_deaths = countries_data['deaths'].find_maxes(scale_population=True, mincases=mindeaths, derivative=False)
for country in ['US', 'China', 'Korea, South', 'Sweden', 'Germany']:
if country not in country_list_deaths:
country_list_deaths.append(country)
color_list_confirmed = generate_colors(len(country_list_confirmed))
color_list_deaths = generate_colors(len(country_list_deaths))
fig, ax = plt.subplots(2, 2, figsize=(12,8))
countries_data['confirmed'].plot_regions(ax[0,0], country_list_confirmed, scale_population=False, color_list=color_list_confirmed)
ax[0,0].set_ylim(1.e4)
ax[0,0].set_yscale('log')
countries_data['deaths'].plot_regions(ax[1,0], country_list_deaths, scale_population=False, color_list=color_list_deaths)
ax[1,0].set_ylim(1.e2)
ax[1,0].set_yscale('log')
countries_data['confirmed'].plot_regions(ax[0,1], country_list_confirmed, scale_population=True, do_legend=False, color_list=color_list_confirmed)
countries_data['confirmed'].plot_regions(ax[0,1], ['World'], scale_population=True, do_legend=True, line_color='k--')
countries_data['deaths'].plot_regions(ax[1,1], country_list_deaths, scale_population=True, do_legend=False, color_list=color_list_deaths)
countries_data['deaths'].plot_regions(ax[1,1], ['World'], scale_population=True, do_legend=True, line_color='k--')
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.55, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
fig.text(0.87, 0.09, f'Top 10 per capita\nwith deaths > {mindeaths},\nplus others')
plot_finish(fig, 'country_cases.png')
if plot_trajectories:
fig, ax = plt.subplots(2, 2, figsize=(12,8))
countries_data['confirmed'].plot_regions_trajectory(ax[0,0], country_list_confirmed, scale_population=False, xymin=100.)
countries_data['deaths'].plot_regions_trajectory(ax[1,0], country_list_deaths, scale_population=False, xymin=100.)
countries_data['confirmed'].plot_regions_trajectory(ax[0,1], country_list_confirmed, scale_population=True, xymin=1.e-6, do_legend=True)
countries_data['deaths'].plot_regions_trajectory(ax[1,1], country_list_deaths, scale_population=True, xymin=1.e-6, do_legend=True)
fig.text(0.87, 0.55, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
fig.text(0.87, 0.09, f'Top 10 per capita\nwith deaths > {mindeaths},\nplus others')
plot_finish(fig, 'country_trajectories.png')
if plot_time_shifted:
fig, ax = plt.subplots(2, 2, figsize=(12,8))
countries_data['confirmed'].plot_regions(ax[0,0], country_list_confirmed, scale_population=False, day_zero_value=100)
countries_data['deaths'].plot_regions(ax[1,0], country_list_deaths, scale_population=False, day_zero_value=100)
countries_data['confirmed'].plot_regions(ax[0,1], country_list_confirmed, scale_population=True, do_legend=True, day_zero_value=1.e-6)
countries_data['deaths'].plot_regions(ax[1,1], country_list_deaths, scale_population=True, do_legend=True, day_zero_value=1.e-6)
fig.text(0.87, 0.55, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
fig.text(0.87, 0.09, f'Top 10 per capita\nwith deaths > {mindeaths},\nplus others')
plot_finish(fig, 'country_cases_shifted.png')
fig, ax = plt.subplots(2, 2, figsize=(12,8))
number_of_days = 30
countries_data['confirmed'].plot_regions(ax[0,0], country_list_confirmed, scale_population=False, derivative=True, do_legend=False, color_list=color_list_confirmed)
ax[0,0].set_ylim(1.)
ax[0,0].set_yscale('log')
countries_data['deaths'].plot_regions(ax[1,0], country_list_deaths, scale_population=False, derivative=True, do_legend=False, color_list=color_list_deaths)
ax[1,0].set_ylim(1.)
ax[1,0].set_yscale('log')
countries_data['confirmed'].plot_regions(ax[0,1], country_list_confirmed, scale_population=True, derivative=True, do_legend=False, number_of_days=number_of_days, color_list=color_list_confirmed)
countries_data['confirmed'].plot_regions(ax[0,1], ['World'], scale_population=True, derivative=True, do_legend=True, line_color='k--', number_of_days=number_of_days)
ax[0,1].set_ylim(0., 0.0010)
countries_data['deaths'].plot_regions(ax[1,1], country_list_deaths, scale_population=True, derivative=True, do_legend=False, number_of_days=number_of_days, color_list=color_list_deaths)
countries_data['deaths'].plot_regions(ax[1,1], ['World'], scale_population=True, derivative=True, do_legend=True, line_color='k--', number_of_days=number_of_days)
ax[1,1].set_ylim(None, 2.e-5)
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.55, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
fig.text(0.87, 0.09, f'Top 10 per capita\nwith deaths > {mindeaths},\nplus others')
plot_finish(fig, 'country_cases_per_day.png')
if plot_doubling_rates:
fig, ax = plt.subplots(2, figsize=(7,8))
countries_data['confirmed'].plot_regions(ax[0], country_list_confirmed, scale_population=False, logderivative=True, do_legend=True)
countries_data['deaths'].plot_regions(ax[1], country_list_deaths, scale_population=False, logderivative=True, do_legend=True)
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.77, 0.55, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
fig.text(0.77, 0.09, f'Top 10 per capita\nwith deaths > {mindeaths},\nplus others')
plot_finish(fig, 'country_doubling_rates.png')
# Plot change of rate
country_list = countries_data['confirmed'].find_maxes(scale_population=True, derivative=False, ncases=30, min_population=1.e7)
fig, ax = plt.subplots(1, figsize=(12,8))
countries_data['confirmed'].plot_regions_rate_change(ax, country_list, scale_population=True)
plot_finish(fig, 'country_change_of_rate_confirmed_plot.png')
fig, ax = plt.subplots(1, figsize=(12,8))
countries_data['deaths'].plot_regions_rate_change(ax, country_list, scale_population=True)
plot_finish(fig, 'country_change_of_rate_deaths_plot.png')
countries_data['confirmed'].plot_regions_rate_change_animate(country_list, scale_population=True,
cases_min = 0.,
cases_max = 0.00026)
####################### States
mincases = 1000
state_list = states_data['confirmed'].find_maxes(scale_population=True, mincases=mincases, derivative=False)
if 'California' not in state_list:
state_list.append('California')
if 'Georgia' not in state_list:
state_list.append('Georgia')
color_list_confirmed = generate_colors(len(state_list))
color_list_deaths = color_list_confirmed
fig, ax = plt.subplots(2, 2, figsize=(12,8))
states_data['confirmed'].plot_regions(ax[0,0], state_list, scale_population=False, color_list=color_list_confirmed)
ax[0,0].set_ylim(1.e3)
ax[0,0].set_yscale('log')
states_data['deaths'].plot_regions(ax[1,0], state_list, scale_population=False, color_list=color_list_deaths)
ax[1,0].set_ylim(1.e2)
ax[1,0].set_yscale('log')
states_data['confirmed'].plot_regions(ax[0,1], state_list, scale_population=True, do_legend=False, color_list=color_list_confirmed)
countries_data['confirmed'].plot_regions(ax[0,1], ['US'], scale_population=True, do_legend=True, line_color='k--')
#ax[0,1].legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.)
states_data['deaths'].plot_regions(ax[1,1], state_list, scale_population=True, color_list=color_list_deaths)
countries_data['deaths'].plot_regions(ax[1,1], ['US'], scale_population=True, line_color='k--')
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'state_cases.png')
if plot_trajectories:
fig, ax = plt.subplots(2, 2, figsize=(12,8))
states_data['confirmed'].plot_regions_trajectory(ax[0,0], state_list, scale_population=False, xymin=100)
states_data['deaths'].plot_regions_trajectory(ax[1,0], state_list, scale_population=False, xymin=100)
states_data['confirmed'].plot_regions_trajectory(ax[0,1], state_list, scale_population=True, do_legend=True, xymin=1.e-6)
states_data['deaths'].plot_regions_trajectory(ax[1,1], state_list, scale_population=True, xymin=1.e-6)
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'state_trajectories.png')
if plot_time_shifted:
fig, ax = plt.subplots(2, 2, figsize=(12,8))
states_data['confirmed'].plot_regions(ax[0,0], state_list, scale_population=False, day_zero_value=20)
states_data['deaths'].plot_regions(ax[1,0], state_list, scale_population=False, day_zero_value=20)
states_data['confirmed'].plot_regions(ax[0,1], state_list, scale_population=True, do_legend=True, day_zero_value=5.e-6)
states_data['deaths'].plot_regions(ax[1,1], state_list, scale_population=True, day_zero_value=5.e-6)
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'state_cases_shifted.png')
fig, ax = plt.subplots(2, 2, figsize=(12,8))
states_data['confirmed'].plot_regions(ax[0,0], state_list, scale_population=False, derivative=True, do_legend=False, color_list=color_list_confirmed)
ax[0,0].set_ylim(1.e1)
ax[0,0].set_yscale('log')
states_data['deaths'].plot_regions(ax[1,0], state_list, scale_population=False, derivative=True, do_legend=False, color_list=color_list_deaths)
ax[1,0].set_ylim(1.)
ax[1,0].set_yscale('log')
states_data['confirmed'].plot_regions(ax[0,1], state_list, scale_population=True, derivative=True, do_legend=False, number_of_days=number_of_days, color_list=color_list_confirmed)
countries_data['confirmed'].plot_regions(ax[0,1], ['US'], scale_population=True, derivative=True, do_legend=True, line_color='k--', number_of_days=number_of_days)
states_data['deaths'].plot_regions(ax[1,1], state_list, scale_population=True, derivative=True, do_legend=False, number_of_days=number_of_days, color_list=color_list_deaths)
countries_data['deaths'].plot_regions(ax[1,1], ['US'], scale_population=True, derivative=True, do_legend=False, line_color='k--', number_of_days=number_of_days)
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'state_cases_per_day.png')
if plot_doubling_rates:
fig, ax = plt.subplots(2, figsize=(7,8))
states_data['confirmed'].plot_regions(ax[0], state_list, scale_population=False, logderivative=True, do_legend=True)
states_data['deaths'].plot_regions(ax[1], state_list, scale_population=False, logderivative=True, do_legend=False)
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.77, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'state_doubling_rates.png')
if plot_scatter_plots:
state_list = states_data['confirmed'].find_maxes(scale_population=True, derivative=False, ncases=30)
# Scatter plot
fig, ax = plt.subplots(2, figsize=(7,8))
states_data['confirmed'].scatter_plot(ax[0], state_list)
states_data['deaths'].scatter_plot(ax[1], state_list)
plot_finish(fig, 'state_scatter_plot.png')
fig, ax = plt.subplots(2, figsize=(7,8))
states_data['confirmed'].scatter_plot(ax[0], state_list, since_days=14)
states_data['deaths'].scatter_plot(ax[1], state_list, since_days=14)
fig.suptitle('In the last 14 days', y=0.04)
plot_finish(fig, 'state_scatter_plot_14days.png')
# Plot change of rate
state_list = states_data['confirmed'].find_maxes(scale_population=True, derivative=False, ncases=500)
if 'California' not in state_list:
state_list.append('California')
fig, ax = plt.subplots(1, figsize=(12,8))
states_data['confirmed'].plot_regions_rate_change(ax, state_list, scale_population=True)
plot_finish(fig, 'state_change_of_rate_confirmed_plot.png')
fig, ax = plt.subplots(1, figsize=(12,8))
states_data['deaths'].plot_regions_rate_change(ax, state_list, scale_population=True)
plot_finish(fig, 'state_change_of_rate_deaths_plot.png')
states_data['confirmed'].plot_regions_rate_change_animate(state_list, scale_population=True,
cases_min = 0.,
cases_max = 0.0005)
####################### Counties
mincases = 100
county_list = counties_data['confirmed'].find_maxes(scale_population=True, mincases=mincases, derivative=False)
#county_list = counties_data['confirmed'].find_maxes(mincases=mincases, derivative=False)
if 'Contra Costa' not in county_list:
county_list.append('Contra Costa')
if 'Alameda' not in county_list:
county_list.append('Alameda')
color_list_confirmed = generate_colors(len(county_list))
color_list_deaths = color_list_confirmed
fig, ax = plt.subplots(2, 2, figsize=(12,8))
counties_data['confirmed'].plot_regions(ax[0,0], county_list, scale_population=False, color_list=color_list_confirmed)
ax[0,0].set_ylim(1.e2)
ax[0,0].set_yscale('log')
counties_data['deaths'].plot_regions(ax[1,0], county_list, scale_population=False, color_list=color_list_deaths)
ax[1,0].set_ylim(1.)
ax[1,0].set_yscale('log')
counties_data['confirmed'].plot_regions(ax[0,1], county_list, scale_population=True, do_legend=False, color_list=color_list_confirmed)
states_data['confirmed'].plot_regions(ax[0,1], ['California'], scale_population=True, do_legend=True, line_color='k--', start_date=datetime.date(2020, 3, 20))
counties_data['deaths'].plot_regions(ax[1,1], county_list, scale_population=True, color_list=color_list_deaths)
states_data['deaths'].plot_regions(ax[1,1], ['California'], scale_population=True, line_color='k--',start_date=datetime.date(2020, 3, 20))
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'county_cases.png')
if plot_trajectories:
fig, ax = plt.subplots(2, 2, figsize=(12,8))
counties_data['confirmed'].plot_regions_trajectory(ax[0,0], county_list, scale_population=False, xymin=1)
counties_data['deaths'].plot_regions_trajectory(ax[1,0], county_list, scale_population=False, xymin=1)
counties_data['confirmed'].plot_regions_trajectory(ax[0,1], county_list, scale_population=True, do_legend=True, xymin=1.e-6)
counties_data['deaths'].plot_regions_trajectory(ax[1,1], county_list, scale_population=True, xymin=1.e-6)
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'county_trajectories.png')
if plot_time_shifted:
fig, ax = plt.subplots(2, figsize=(7,8))
counties_data['confirmed'].plot_regions(ax[0], county_list, do_legend=True, day_zero_value=10)
counties_data['deaths'].plot_regions(ax[1], county_list, do_legend=False, day_zero_value=10)
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'county_cases_shifted.png')
fig, ax = plt.subplots(2, 2, figsize=(12,8))
counties_data['confirmed'].plot_regions(ax[0,0], county_list, scale_population=False, derivative=True, do_legend=False, color_list=color_list_confirmed)
ax[0,0].set_ylim(1.)
ax[0,0].set_yscale('log')
counties_data['deaths'].plot_regions(ax[1,0], county_list, scale_population=False, derivative=True, do_legend=False, color_list=color_list_deaths)
ax[1,0].set_ylim(1.)
ax[1,0].set_yscale('log')
counties_data['confirmed'].plot_regions(ax[0,1], county_list, scale_population=True, derivative=True, do_legend=False, number_of_days=number_of_days, color_list=color_list_confirmed)
states_data['confirmed'].plot_regions(ax[0,1], ['California'], scale_population=True, derivative=True, do_legend=True, line_color='k--', number_of_days=number_of_days)
#ax[0,1].set_ylim(None, 0.0004)
counties_data['deaths'].plot_regions(ax[1,1], county_list, scale_population=True, derivative=True, do_legend=False, number_of_days=number_of_days, color_list=color_list_deaths)
states_data['deaths'].plot_regions(ax[1,1], ['California'], scale_population=True, derivative=True, do_legend=False, line_color='k--', number_of_days=number_of_days)
ax[1,1].set_ylim(None, 2.e-5)
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'county_cases_per_day.png')
if plot_doubling_rates:
fig, ax = plt.subplots(2, figsize=(7,8))
counties_data['confirmed'].plot_regions(ax[0], county_list, logderivative=True, do_legend=True)
counties_data['deaths'].plot_regions(ax[1], county_list, logderivative=True, do_legend=False)
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.77, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'county_doubling_rates.png')
# Plot change of rate
county_list = counties_data['confirmed'].find_maxes(scale_population=True, derivative=False, ncases=50)
#print(county_list)
fig, ax = plt.subplots(1, figsize=(12,8))
counties_data['confirmed'].plot_regions_rate_change(ax, county_list, scale_population=True)
plot_finish(fig, 'county_change_of_rate_confirmed_plot.png')
fig, ax = plt.subplots(1, figsize=(12,8))
counties_data['deaths'].plot_regions_rate_change(ax, county_list, scale_population=True)
plot_finish(fig, 'county_change_of_rate_deaths_plot.png')
counties_data['confirmed'].plot_regions_rate_change_animate(county_list, scale_population=True,
cases_min = 0.,
cases_max = 0.0004)
"""
# The format for the dates keeps changing
# -------- with hospitalization counts
county_list = california_data.find_maxes(which='COVID-19 Positive Patients', scale_population=True, mincases=50)
if 'Contra Costa' not in county_list:
county_list.append('Contra Costa')
fig, ax = plt.subplots(2, 2, figsize=(12,8))
california_data.plot_regions(ax[0,0], county_list, which='COVID-19 Positive Patients', scale_population=True, ylabel='New confirmed patients per capita')
california_data.plot_regions(ax[1,0], county_list, which='ICU COVID-19 Positive Patients', scale_population=True, ylabel='New confirmed ICU patients per capita')
california_data.plot_regions(ax[0,1], county_list, which='Suspected COVID-19 Positive Patients', scale_population=True, do_legend=True, ylabel='New suspected patients per capita')
california_data.plot_regions(ax[1,1], county_list, which='ICU COVID-19 Suspected Patients', scale_population=True, ylabel='New suspected ICU patients per capita')
# set nice formatting and centering for dates
fig.autofmt_xdate()
fig.text(0.87, 0.58, f'Top 10 per capita\nwith cases > {mincases},\nplus others')
plot_finish(fig, 'county_hospitalization.png')
"""
fig, ax = plt.subplots(figsize=(12,8))
counties_data['confirmed'].plot_map(fig, ax, derivative=True)
fig.suptitle('data from https://github.com/CSSEGISandData/COVID-19', y=0.02)
fig.savefig('../../Dropbox/Public/COVID19/CA_map_cases_per_day.png')
fig, ax = plt.subplots(figsize=(12,8))
counties_data['confirmed'].plot_map(fig, ax, derivative=False)
fig.suptitle('data from https://github.com/CSSEGISandData/COVID-19', y=0.02)
fig.savefig('../../Dropbox/Public/COVID19/CA_map_cumulative_cases.png')
####################### Death rates
if plot_death_rates:
fig, ax = plt.subplots(3, figsize=(12,8))
plotcountries_delayed_death_rates(ax[0], country_list_deaths, countries_data, do_legend=True)
plotstates_delayed_death_rates(ax[1], state_list, states_data, do_legend=True, ymax=0.1)
plotcounties_delayed_death_rates(ax[2], county_list, counties_data, do_legend=True, ymax=0.1)
if delay > 0:
fig.suptitle(f'Confirmed cases lagged by {delay} days', y=0.96)
plot_finish(fig, 'delayed_death_rates.png')