def save_plots(mr, res_id, is_save_plots, is_show_plots): multiple_categories_to_plot = [ 'E', 'A', 'I', 'R', 'H', 'C', 'D', 'O', 'Q', 'U' ] # categories to plot single_category_to_plot = 'C' # categories to plot in final 3 plots #TODO: make selectable # plot graphs sol = mr.get('standard_sol') percentiles = mr.get('percentiles') p = mr.get('params') fig_multi_lines = go.Figure( figure_generator( sol, p, multiple_categories_to_plot)) # plot with lots of lines fig_age_structure = go.Figure( age_structure_plot(sol, p, single_category_to_plot)) fig_bar_chart = go.Figure(stacked_bar_plot( sol, p, single_category_to_plot)) # bar chart (age structure) fig_uncertainty = go.Figure( uncertainty_plot(sol, p, single_category_to_plot, percentiles)) # uncertainty if is_show_plots: fig_multi_lines.show() fig_age_structure.show() fig_bar_chart.show() fig_uncertainty.show() if is_save_plots: fig_multi_lines.write_image( pu.fig_path(f"Disease_progress_{res_id}.png")) fig_age_structure.write_image( pu.fig_path(f"Age_structure_{res_id}.png")) fig_bar_chart.write_image( pu.fig_path(f"Age_structure_(bar_chart)_{res_id}.png")) fig_uncertainty.write_image(pu.fig_path(f"Uncertainty_{res_id}.png"))
def charts(mr): sol = mr.get('standard_sol') percentiles = mr.get('percentiles') p = mr.get('params') multiple_categories_to_plot = [ 'E', 'A', 'I', 'R', 'H', 'C', 'D', 'O', 'Q', 'U' ] # categories to plot # categories to plot in final 3 plots #TODO: make selectable single_category_to_plot = 'C' fig_multi_lines = go.Figure( figure_generator( sol, p, multiple_categories_to_plot)) # plot with lots of lines fig_age_structure = go.Figure( age_structure_plot(sol, p, single_category_to_plot)) fig_bar_chart = go.Figure(stacked_bar_plot( sol, p, single_category_to_plot)) # bar chart (age structure) fig_uncertainty = go.Figure( uncertainty_plot(sol, p, single_category_to_plot, percentiles)) # uncertainty return html.Div([ dbc.Row([ dbc.Col(html.Div([ html.H6('Disease progress'), html. P('This plot illustrates the disease spread spread for the associated categories' ), dcc.Graph(id='fig_multi_lines', figure=fig_multi_lines) ]), width=20) ], style={ 'marginLeft': 'auto', 'marginRight': 'auto', 'width': '50%' }), dbc.Row([ dbc.Col(html.Div([ html.H6('Age Structure (Bar chart)'), html. P('This plot illustrates the age structure distribution for the selected category' ), dcc.Graph(id='fig_bar_chart', figure=fig_bar_chart) ]), width=20), ], style={ 'marginLeft': 'auto', 'marginRight': 'auto', 'width': '50%' }), dbc.Row([ dbc.Col(html.Div([ html.H6('Uncertainty'), html. P('This plot models the uncertainty in the population distribution for the selected category' ), dcc.Graph(id='fig_uncertainty', figure=fig_uncertainty) ]), width=20) ], style={ 'marginLeft': 'auto', 'marginRight': 'auto', 'width': '50%' }) ])