plot

Plot tools module.

This module is based on Matplotlib.

Hint

Use pip to install the necessary dependencies for this module: pip install mltb2[plot]

mltb2.plot.boxplot(values, labels=None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, vert: bool = True)[source]

Prints one or more boxplots in a single diagram.

Hint

This function does not use matplotlib.pyplot.plot.

Parameters:
  • values – Values for the boxplot(s).

  • labels – Labels for the boxplot(s).

  • title (str | None) – Title of the plot.

  • xlabel (str | None) – Label for the x-axis.

  • ylabel (str | None) – Label for the y-axis.

  • vert (bool) – If True (default), makes the boxes vertical. If False, makes horizontal boxes.

mltb2.plot.boxplot_dict(values_dict, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, vert: bool = True)[source]

Create boxplot form dictionary.

Hint

This function does not use matplotlib.pyplot.plot.

Parameters:
  • values_dict – Dictionary with values for the boxplot(s).

  • title (str | None) – Title of the plot.

  • xlabel (str | None) – Label for the x-axis.

  • ylabel (str | None) – Label for the y-axis.

  • vert (bool) – If True (default), makes the boxes vertical. If False, makes horizontal boxes.

mltb2.plot.save_last_figure(filename)[source]

Saves the last plot made by Matplotlib.

For jupyter notebooks this has to be called in the same cell that created the plot.

mltb2.plot.twin_axes_timeseries_plot(values_1, label_1: str, values_2, label_2: str, start_timestep_number: int = 0, shift_1: int = 0, shift_2: int = 0, title: str | None = None, label_x: str = 'Step', color_1: str = 'tab:red', color_2: str = 'tab:blue')[source]

Create twin axes timeseries plot.

Plots two different timeseries curves in one diagram but two different y-axes.

Hint

This function does not use matplotlib.pyplot.plot.

Parameters:
  • values_1 – (array_like) Values for the first timeseries curve.

  • label_1 (str) – Label for the first timeseries curve.

  • values_2 – (array_like) Values for the second timeseries curve.

  • label_2 (str) – Label for the second timeseries curve.

  • start_timestep_number (int) – Number for first point in time. Default is 0.

  • shift_1 (int) – Number of timesteps to shift the first timeseries curve. Can be positive or negative. Default is 0.

  • shift_2 (int) – Number of timesteps to shift the second timeseries curve. Can be positive or negative. Default is 0.

  • title (str | None) – Title of the plot.

  • label_x (str) – Label for the x-axis (timeseries axis). Default is ‘Step’.

  • color_1 (str) – Color of first timeseries curve. Default is ‘tab:red’.

  • color_2 (str) – Color of second timeseries curve. Default is ‘tab:blue’.