def make_jhu_state_cases_chart(override_props) -> CovidChart: jhu_df = pd.read_csv('./data/jhu-data.csv') # grab us-specific jhu_df = jhu_df[(jhu_df.Country_Region == 'United States') & jhu_df.Province_State.notnull()] if STAGING: level = 'usa' # qcsv = './data/quarantine-activity-US-Apr16.csv' qcsv = './data/combined-activity-US-Jun9.csv' else: level = 'usa_old' qcsv = './data/quarantine-activity-US.csv' days_since = 20 groupcol = 'Province_State' chart = CovidChart( jhu_df, groupcol=groupcol, start_criterion=DaysSinceNumReached(days_since, 'Confirmed'), ycol='Confirmed', level=level, xcol='Date', top_k_groups=30, sample_every=3, quarantine_df=qcsv # should have a column with same name as `groupcol` ) # chart.set_colormap() chart.set_unfocused_opacity(0.05) chart = chart.set_ytitle('Number of Confirmed Cases (log scale)') chart = chart.set_xtitle([ 'Days since {} Confirmed'.format(days_since), '(Events prior to Day 0 not shown)' ]) chart.set_width(600).set_height(400) chart.set_xdomain((0, 47 + EXTRA_DAYS_TO_INCLUDE)).set_ydomain( (days_since, 1000000)) chart.click_selection_init = first_alphabetic_group( chart._preprocess_df(), groupcol) chart = _maybe_add_staging_props(chart) chart.spec.update(override_props) return chart
def make_jhu_state_death_chart() -> CovidChart: jhu_df = pd.read_csv('./data/jhu-data.csv') jhu_df = jhu_df.loc[(jhu_df.Country_Region == 'United States') & jhu_df.Province_State.notnull()] chart = CovidChart( jhu_df, groupcol='Province_State', start_criterion=DaysSinceNumReached(10, 'Deaths'), ycol='Deaths', xcol='Date', chart_type='usa', top_k_groups=20, quarantine_df= './data/quarantine-activity-us.csv' # should have a column with same name as `groupcol` ) chart = chart.set_ytitle('Number of Deaths (log)') chart = chart.set_xtitle('Days since 10 Deaths') chart.set_width(600).set_height(400) chart.set_ydomain((10, 10000)) chart.set_xdomain((0, 25)).compile() return chart
def make_jhu_country_cases_chart(override_props) -> CovidChart: jhu_df = pd.read_csv('./data/jhu-data.csv') jhu_df = jhu_df[(jhu_df.Province_State.isnull()) & (jhu_df.Country_Region != 'China')] #qcsv = './data/quarantine-activity-Apr19.csv' qcsv = './data/quarantine-activity-world-new-export.csv' days_since = 50 groupcol = 'Country_Region' chart = CovidChart(jhu_df, groupcol=groupcol, start_criterion=DaysSinceNumReached( days_since, 'Confirmed'), ycol='Confirmed', level='country', xcol='Date', top_k_groups=30, sample_every=3, quarantine_df=qcsv) # chart.set_colormap() chart.set_unfocused_opacity(0.05) chart = chart.set_ytitle('Number of Confirmed Cases (log scale)') chart = chart.set_xtitle([ 'Days since {} Confirmed'.format(days_since), '(Events prior to Day 0 not shown)' ]) chart.set_width(600).set_height(400) chart.set_ydomain((days_since, 1000000)) chart.set_xdomain((0, 72 + EXTRA_DAYS_TO_INCLUDE)) chart.click_selection_init = first_alphabetic_group( chart._preprocess_df(), groupcol) chart = _maybe_add_staging_props(chart) chart.spec.update(override_props) return chart