emodpy_hiv.plotting.plot_inset_chart module#

This module contains methods for plotting channel reports (i.e. InsetChart).

emodpy_hiv.plotting.plot_inset_chart.get_raw_color(idx: int)[source]#

When plotting the raw data as background, use a lighter color than the test data. Needs to be synchronized with get_color_name().

Parameters:

idx – index of the plot used to select color

Returns:

Matplotlib basic color to use for plotting.

emodpy_hiv.plotting.plot_inset_chart.get_color_name(idx: int)[source]#

Return name of color that should be returned by getColor() given the same input value. Needs to be synchronized with get_raw_color().

Parameters:

idx – index of the plot used to select color

Returns:

Name of the basic color to use for plotting in matplotlib.

emodpy_hiv.plotting.plot_inset_chart.get_list_of_channels(ref_data: dict, test_data: list[dict])[source]#

Returns a list of the unique channel names used in both the reference data and the test data. This should enable the display of all of the channels even when both reports do not have the same channels.

Parameters:
  • ref_data – channel report, json dictionary consider to contain the baseline data

  • test_data – a list of channel reports (dictionaries) containing data to compare to

Returns:

Unique list of channels from all the channels in the input

emodpy_hiv.plotting.plot_inset_chart.create_title_string(reference: str, data_filenames: list[str])[source]#

Returns a string that contains the input file names where the color used in plotting is included in the name. This can be used as the title of the plot.

Parameters:
  • reference – name of the reference data file

  • data_filenames – a list of the test data file names

Returns:

A string where each file name is on its own line and includes the color to be used in plotting in the name.

emodpy_hiv.plotting.plot_inset_chart.get_data_from_directory(directory: str)[source]#

Gets the JSON files from the input directory and return the names of the files and the dictionaries of data. The idea is to allow the user to put several channel reports into one directory and plot them all by just giving the name of the directory.

Parameters:

directory – a path to a directory that contains only a collection of channel reports

Returns:

Return the list of file names in the directory AND the list of dictionaries containing the data of those files

emodpy_hiv.plotting.plot_inset_chart.plot_subplot(chan_title: str, data: dict, color: str, linewidth: int, subplot: Axes)[source]#
emodpy_hiv.plotting.plot_inset_chart.plot_data(title: str, ref_data: dict | None = None, test_data: list[dict] | None = None, raw_data_list_of_lists: list[list[dict]] | None = None, test_filenames: list[str] | None = None, subplot_index_min: int = 0, subplot_index_max: int = 100, img_dir: str | None = None, plot_name: str | None = None)[source]#

Plot the data such that there is a grid of subplots with each subplot representing a “channel” of data. Each subplot will have time on the x-axis and the units of that channel on the y-axis.

Parameters:
  • title – The string to put at the top of the page

  • ref_data – A channel report dictionary whose data will be plotted in red

  • test_data – A list of channel report dictionaries whose data will be plotted in colors other than red

  • test_file_names – The list of file names in parallel to the test_data.

  • subplot_index_min – The index of the first subplot to show based on the alphabetical order of the channels in the report.

  • subplot_index_min – The index of the last subplot to show based on the alphabetical order of the channels in the report.

  • img_dir – The name of the directory to save the images to. If not provided, it will open a window.

  • plot_name – If provided the name of the file for the saved image.

Returns:

Nothing

emodpy_hiv.plotting.plot_inset_chart.plot_inset_chart(dir_name: str | None = None, reference: str | None = None, comparison1: str | None = None, comparison2: str | None = None, comparison3: str | None = None, title: str | None = None, include_filenames_in_title=True, output: str | None = None)[source]#

Plot the inset chart using the provided parameters.

Parameters:
  • dir_name – Directory containing channel reports with .json extension

  • reference – Reference channel report filename

  • comparison1 – Comparison1 channel report filename

  • comparison2 – Comparison2 channel report filename

  • comparison3 – Comparison3 channel report filename

  • title – Title of Plot

  • include_filenames_in_title – If true, includes the filenames in the title (needed for testing)

  • output – If provided, a directory will be created and images saved to the folder. If not provided, it opens windows.

Returns:

Nothing