# fig = px.bar(tests, x='Date', y=['Positives', 'Tests'], barmode='group')
# pplot(fig, include_plotlyjs='cdn', filename=plotpath+'\\temp1.html')

# Make separate lines for each day of the week
# fig = px.line(tests, x='Date', y='Positives', color='Weekday')
# pplot(fig, include_plotlyjs='cdn', filename=plotpath+'\\temp2.html')

#%% Plot tests by result date

# remember below shows 7-day average positivity as average of the positivity,
# not more correctly positivity of the averages.

covid.plotly_twolines(
    tests,
    'Positivity',
    'Positives',
    plotcolors=['violet', 'steelblue', 'thistle'],
    secondary_scale=3e4,
    savefile=plotpath + '\\Pos-Positivity-ByResult-WI.html',
)

# covid.plotly_casetest(sourcedata=tests,
#                       case_col='Positives',
#                       test_col='Tests',
#                       date_col='Date',
#                       savefile=plotpath + '\\Pos-Test-ByResult-WI.html',
#                       )

#%% Cases by test date for Wisconsin
filename = 'C:\dev\covid-wisconsin\data\Cases_with_prob_stacked_data_2021-01-08.csv'

wi = pd.read_csv(filename)
Exemple #2
0
            marker='.')

#%%
quit()

#%% Plot all cases vs. deaths

savefile = '.\\docs\\assets\\plotly\\Surge-Predictor.html'

fig = covid.plotly_twolines(
    state,
    'Positivity',
    'Cases',
    plotcolors=['violet', 'steelblue'],
    secondary_scale=1e4,
    # plotlabels = {'title': 'Surge Detector<br>(assuming CFR '+str(CFR)+'%)',
    #               'yaxis': 'Deaths',
    #               'yaxis_secondary': 'Cases',
    #               },
    column1_bar=True,
    savefile=savefile,
)

# # save_png = '.\\docs\\assets\\Cases-Deaths-WI_2020-12-06.png'
# save_png = '.\\docs\\assets\\Cases-Deaths-WI.png'
# fig.write_image(
#     save_png,
#     width=900,
#     height=600,
#     engine='kaleido',
# )
Exemple #3
0
pos_df = pos_df[pos_df.Date < pos_df.Date.max()]

#%% Plotly plot for cases / positivity
plotpath = '.\\docs\\_includes\\plotly'
savefile = plotpath+'\\Pos-Positivity-WI.html'


fig = covid.plotly_twolines(
    pos_df, 
    'Positive tests', 
    'Percent positive',
    plotcolors=['steelblue', 'darkmagenta', 'lightsteelblue'],
    secondary_scale=1/25000,
    date_min=datetime.datetime(2021,1,15),
    range_max=2000,
    col1_mode='avg-bar',
    col2_mode='line',
    plotlabels = {'title': 'WI Positive Tests and Percent Positive',
                  'yaxis': 'Positve tests',
                  'yaxis_secondary': 'Percent positive',
                  },
    savefile=savefile,
    showfig=False,
    )

fig.update_xaxes(title_text='Date of test result')
fig.update_yaxes(secondary_y=True, tickformat=',.0%')
fig.update_traces(secondary_y=True, hovertemplate='%{y:.1%}')

fig.write_html(
    file=savefile,
    file=htmlfile,
    default_height=500,
    default_width=700,
    include_plotlyjs='cdn',
)

os.startfile(htmlfile)

fig.write_image(
    save_png,
    width=700,
    height=500,
    engine='kaleido',
)
os.startfile(save_png)

#%% Compare cases and hospitalizations?
covid.plotly_twolines(
    state,
    'POS_NEW',
    'HOSP_NEW',
    plotcolors=['steelblue', 'darkorange'],
    secondary_scale=0.05,
    plotlabels=dict(
        title='WI Daily Cases and Hospitalizations',
        yaxis='Cases',
        yaxis_secondary='Hospitalizations',
    ),
    savefile='docs\\assets\\plotly\\Cases-Hosp-WI.html',
)
    'POS_NEW': 'Cases',
    'TEST_NEW': 'Tests',
    'DTH_NEW': 'Deaths',
    'HOSP_NEW': 'Hospitalizations'
}
mke = mke.rename(columns=col_rename)

savefile = '.\\docs\\assets\\plotly\\Cases-Hosp-Milwaukee.html'

fig = covid.plotly_twolines(
    mke,
    'Hospitalizations',
    'Cases',
    plotcolors=['darkorange', 'steelblue', 'burlywood'],
    secondary_scale=10,
    plotlabels={
        'title': 'Milwaukee Daily Cases and Hospitalizations',
        'yaxis': 'Hospitalizations',
        'yaxis_secondary': 'Cases',
    },
    column1_bar=True,
    savefile=savefile,
)

fig.add_annotation(
    x=datetime.datetime(2020, 5, 11),
    y=45,
    xanchor='right',
    align='right',
    text=
    '950 hospitalizations<br>from prior days<br>reported on May 11<br>(not pictured)'
)
Exemple #6
0
state = state.set_index('Date')
state[delay_str] = deaths
state = state.reset_index()

#%% Plot all cases vs. deaths
CFR = 1.0

savefile = '.\\docs\\assets\\plotly\\Cases-Deaths-WI.html'

fig = covid.plotly_twolines(
    state,
    delay_str,
    'Cases',
    plotcolors=['firebrick', 'steelblue', 'rosybrown'],
    secondary_scale=1 / (CFR / 100),
    plotlabels={
        'title': 'WI Deaths and Cases<br>(assuming CFR ' + str(CFR) + '%)',
        'yaxis': 'Deaths',
        'yaxis_secondary': 'Cases',
    },
    column1_bar=True,
    savefile=savefile,
)

# save_png = '.\\docs\\assets\\Cases-Deaths-WI_2020-12-06.png'
save_png = '.\\docs\\assets\\Cases-Deaths-WI.png'
fig.write_image(
    save_png,
    width=900,
    height=600,
    engine='kaleido',
)
Exemple #7
0
plotpath = '.\\docs\\assets\\plotly'

# covid.plotly_twolines(
#     pos_df,
#     'Percent Positive',
#     'Positive',
#     plotcolors=['violet', 'steelblue', 'thistle'],
#     secondary_scale=300,
#     savefile=plotpath+'\\Pos-Positivity-WI.html',
#     )

covid.plotly_twolines(
    pos_df,
    'Positive',
    'Percent Positive',
    plotcolors=['steelblue', 'violet', 'lightsteelblue'],
    secondary_scale=1 / 200,
    range_max=8000,
    savefile=plotpath + '\\Pos-Positivity-WI.html',
)

covid.plotly_twolines(
    pos_df,
    'Positive',
    'Tests',
    plotcolors=['steelblue', 'olivedrab', 'lightsteelblue'],
    secondary_scale=10,
    range_max=8000,
    savefile=plotpath + '\\Pos-Tests-WI.html',
)