Plotting and Visual Management

The plotting module is used for automatically managing visuals, like a sort of wrapper for MatPlotLib directives. The most core object here is GraphingOptions, which is utilized to create standardized visuals through having a standard settings for all graphs produced.

class experimentalis.plotting.GraphingOptions(x_label='', y_label='', x_units=None, y_units=None, data_marker='.', data_marker_size=2, data_linestyle='', data_alpha=0.8, data_color='C0', model_marker='', model_linestyle='-', model_linewidth=2, model_alpha=1.0, model_color='darkred', data_round=1)

Bases: object

A standardized structure for creating visuals with the same layout and style, such that each plot doesn’t need to be configured manually.

Parameters:
  • x_label (str) – The label along the x-axis.

  • y_label (str) – The label along the y-axis.

  • x_units (str) – The units of x (optional).

  • y_units (str) – The units of y (optional).

  • data_round – The current round of data collection, used for

automatic title generation. :type data_round: int

data_alpha = 0.8
data_color = 'C0'
data_linestyle = ''
data_marker = '.'
data_marker_size = 2
data_round = 1
default_title()

Automatically generates a default title for data plotted to a figure, which is just the dependent and independent variables alongside the round number.

Returns:

The default title

Return type:

str

model_alpha = 1.0
model_color = 'darkred'
model_linestyle = '-'
model_linewidth = 2
model_marker = ''
plot_datasets(datasets, labels=None, colors=None)

Plots multiple datasets to the image, with optional, but highly recommended custom labels and colors.

Parameters:
  • datasets (list[Dataset]) – A list of the datasets to plot.

  • labels (list[str]) – A list of the labels for each dataset.

  • colors (list[str]) – A list of the colors for each series.

plot_individual_dataset(data, label=None, color=None)

Plots an individual dataset to an active figure.

Parameters:
  • data (Dataset) – The dataset to plot

  • label (str) – The label for this dataset

  • color (str) – The color for this plot

plot_model(model_x, model_y)

Plots a model curve to an active plot.

Parameters:
  • model_x (NDArray) – The x-values for the model.

  • model_y (NDArray) – The y-values for the model.

plot_residuals(x, residuals, y_uncert)

Produces a residuals plot for a model.

Parameters:
  • x (NDArray) – The x-values of the data.

  • residuals (NDArray) – The residuals from the model.

  • y_uncert (NDArray) – The uncertainty in each residual/datapoint.

static save_graph_and_close()

Saves the active figure to a png-representation variable for ease of display or saving later.

from matplotlib import pyplot as plt
from IPython import display

graphing_options = GraphingOptions(...)

plt.figure()

# some plotting code ..

figure = graphing_options.save_graph_and_close()

# other things

display(figure)
set_labels(xlabel=None, ylabel=None)

Automatically sets the labels for a the next figure based on whether or not the label names are configured to use units.

Parameters:

xlabel – Optional label for the x-axis, otherwise defaults

to the label previously set. :type xlabel: str :type ylabel: str

x_label = ''
x_units = None
y_label = ''
y_units = None