bucky.viz.plot
Creates line plots with confidence intervals at the ADM0, ADM1, or ADM2 level.
add_col_data_to_plot(axis, col, sim_data, quantiles_list)
add_col_data_to_plot
Adds simulation data for requested column to initialized matplotlib axis object.
add_hist_data_to_plot(axis, historical_data, adm_key, adm_value, col, sim_max_date)
add_hist_data_to_plot
Add historical data for requested column and area to initialized matplotlib axis object.
get_plot_title(l_table, adm_key, adm_value)
get_plot_title
Determine plot title for a given area based on adm code and lookup table.
main(args=None)
main
Main entrypoint.
make_plots(adm_levels, input_directory, output_directory, lookup_df, plot_hist, plot_columns, quantiles, window_size, end_date, hist_file, min_hist_points, admin1=None, hist_start=None)
make_plots
Wrapper function around plot. Creates plots, aggregating data if necessary.
plot(out_dir, lookup_df, key, sim_data, hist_data, plot_columns, quantiles)
plot
Given a dataframe and a key, creates plots with requested columns.
preprocess_historical_dates(historical_data, hist_start_date, plot_start, plot_end, min_data_points)
preprocess_historical_dates
Check that historical data has the correct date range and requested number of data points.
bucky.viz.plot.
default_plot_cols
parser
axis (matplotlib.axes.Axes) – Previously initialized axis object
matplotlib.axes.Axes
col (str) – Column to add to plot
str
sim_data (pandas.DataFrame) – Area simulation data
pandas.DataFrame
quantiles_list (list of float, or None) – List of quantiles to plot. If None, will plot all available quantiles in data.
list
float
None
axis – Modified axis object with added data
historical_data (pandas.DataFrame) – Dataframe of historical data
adm_key (str) – Admin key to use to relate simulation data and geographic areas
adm_value (int) – Admin code value for area
int
sim_max_date (pandas.Timestamp) – Latest date in simulation data
pandas.Timestamp
For ADM0 and ADM1 plots, uses names. For ADM2 plots, the ADM1 name is included in addition to the ADM2 name.
l_table (pandas.DataFrame) – Dataframe containing information relating different geographic areas
adm_key (str) – Admin level key
plot_title – Formatted string to use for plot title
adm_levels (list of str) – List of ADM levels to make plots for
input_directory (str) – Location of simulation data
output_directory (str) – Parent directory to place created plots.
lookup_df (pandas.DataFrame) – Lookup table for geographic mapping information
plot_hist (bool) – If True, will plot historical data.
bool
plot_columns (list of str) – List of columns to plot from data.
quantiles (list of float, or None) – List of quantiles to plot. If None, will plot all available quantiles in data.
window_size (int) – Size of window (in days) to apply to historical data.
end_date (str) – Plot data until this date. Must be formatted as YYYY-MM-DD. If None, uses last date in simulation.
hist_file (str) – Path to historical data file. If None, uses either CSSE or Covid Tracking data depending on columns requested.
min_hist_points (int) – Minimum number of historical data points to plot.
admin1 (list of str, or None) – List of admin1 values to make plots for. If None, a plot will be created for every unique admin1 values. Otherwise, plots are only made for those requested.
hist_start (str, or None) – Plot historical data from this point (formatted as YYYY-MM-DD). If None, aligns with simulation start date.
For example, a pandas.DataFrame with state-level data would create a plot for each unique state. Simulation data is plotted as a line with shaded confidence intervals. Historical data is added as scatter points if requested.
out_dir (str) – Location to place created plots.
lookup_df (pandas.DataFrame) – Dataframe containing information relating different geographic areas
key (str) – Key to use to relate simulation data and geographic areas. Must appear in lookup and simulation data (and historical data if applicable)
sim_data (pandas.DataFrame) – Simulation data to plot
hist_data (pandas.DataFrame) – Historical data to add to plot
plot_columns (list of str) – Columns to plot
historical_data (pandas.DataFrame) – Dataframe with requested historical data
hist_start_date (str or None) – Plot historical data from this point (formatted as YYYY-MM-DD). If None, aligns with simulation start date.
plot_start (pandas.Timestamp) – Earliest date appearing in simulation data
plot_end (pandas.Timestamp) – Latest date appearing in simulation data
min_data_points (int) – Minimum number of historical data points to plot
historical_data – Historical data with the correct date range and number of points
bucky.viz.map
bucky.make_input_graph