emodpy_hiv.plotting.xy_plot module#

emodpy_hiv.plotting.xy_plot.create_common_x_values(a_old, b_old)[source]#

Matplotlib needs the x-values to be the same for different (x,y) lines being plotted. This method creates a new version of each set of values.

emodpy_hiv.plotting.xy_plot.fill_in_y_values(x_old, y_old, x_new)[source]#

Since matplotlib needs the lines/curves to have the same X-values, we need to find the associated Y-values when we add the new X-values. This method uses linear interpolation to find the values between points.

emodpy_hiv.plotting.xy_plot.get_color_name(idx: int)[source]#
emodpy_hiv.plotting.xy_plot.get_line_style(idx: int)[source]#
emodpy_hiv.plotting.xy_plot.get_marker_style(idx: int)[source]#
emodpy_hiv.plotting.xy_plot.xy_plot(img_dir: str, df: DataFrame, title_1: str, title_2: str, x_axis_name: str = 'Years', y_axis_name: str = '', expected_df: DataFrame | None = None, fraction_of_total: bool = False, show_legend: bool = True, show_markers: bool = True, min_x: float | None = None, max_x: float | None = None, min_y: float | None = None, max_y: float | None = None, x_axis_as_log_scale: bool = False, y_axis_as_log_scale: bool = False)[source]#

Create a plot using the give dataframe, ‘df’, with all of the appropriate labels. The index of the dataframe will be used for the X-axis and the lines or curves will be for each column of the dataframe.

Parameters:
  • img_dir (str, required) – Directory to save the images. If None, the images will not be saved and a window will be opened.

  • df (DataFrame, required) – A dataframe where the index will be used for the X-values and each column will get a separate line/curve. The name of the column will be used in the legend.

  • title_1 (str, required) – This will be the top line text on the plot.

  • title_2 (str, required) – This will be the second line of text ohe plot.

  • x_axis_name (str, optional) – This is the label used to indicate what the X-axis values are.

  • y_axis_name (str, optional) – This is the label used to indicate what the Y-axis values are.

  • expected_df (DataFame, optional) – This dataframe is expected to have a similar format to the ‘df’ dataframe. The index of the dataframe is the X-values and should similar to that of ‘df’. The columns are the Y-values and each column creates a separate line/curve. However, these will be plotted in black, the markers a little larger, and on top of the lines from the ‘df’.

  • fraction_of_total (bool, optional) – If true, the columns of each dataframe are summed and divided by this sum to create a fraction of the total.

  • show_legend (bool, optional) – If True a legend will be placed on the right side of the plot, but beware that long column names can make the plot space very small.

  • show_markers (bool, optional) – if True the lines will have markers at each data point.

  • min_x (float, optional) – If provided the plot will have a fixed minimum value for the X-axis independent of the data. When not provided, matplotlib determines the minimum based on the data.

  • max_x (float, optional) – If provided the plot will have a fixed maximum value for the X-axis independent of the data. When not provided, matplotlib determines the minimum based on the data.

  • min_y (float, optional) – If provided the plot will have a fixed minimum value for the Y-axis independent of the data. When not provided, matplotlib determines the minimum based on the data.

  • max_y (float, optional) – If provided the plot will have a fixed maximum value for the Y-axis independent of the data. When not provided, matplotlib determines the minimum based on the data.

  • x_axis_as_log_scale (bool, optional) – If True, the X-axis is assumed to be logrithmic.

  • y_axis_as_log_scale (bool, optional) – If True, the Y-axis is assumed to be logrithmic.

Returns:

None - but image will be saved or window opened.