# Plot Utilities Module

This module contains functions and classes for advanced plotting tasks, including visualization of samples, optimization history, eigenvalue plots, intensity histograms, and overlayed histograms.

## Functions

encoding_information.plot_utils.plot_samples(samples, ground_truth, model_names=['Samples'], contrast_cutoff=99)

  Plot ground truth data and samples from model(s).

  Parameters:

    - samples (list of np.ndarray) – List of samples from models. Each array represents model output.

    - ground_truth (np.ndarray) – Ground truth data for comparison.

    - model_names (list of str, optional) – List of names corresponding to each model.

    - contrast_cutoff (int, optional) – Percentile to determine contrast cutoff for display. Defaults to 99.

encoding_information.plot_utils.plot_optimization_loss_history(val_loss_history)

  Plot the validation loss history during an optimization process.

  Parameters:

    val_loss_history (list of float) – A list representing the history of validation loss over iterations.

encoding_information.plot_utils.plot_eigenvalues(*args, **kwargs)

  Plot the eigenvalues of a set of covariance matrices.

  Parameters:

    - *args (list of np.ndarray) – Covariance matrices to plot eigenvalues from.

    - **kwargs (dict) – Named arguments where the name is the label and the value is the covariance matrix.

encoding_information.plot_utils.plot_intensity_coord_histogram(ax, intensities_1, intensities_2, max, cmap=None, bins=50, colors=None, color=None, plot_center_coords=None, black_background=False, show_colorbar=True, **kwargs)

  Plot 2D histograms of intensity coordinates from two groups of intensities.

  Parameters:

    - ax (matplotlib.axes.Axes) – The axis on which to plot.

    - intensities_1 (np.ndarray) – Intensity values for the x-axis.

    - intensities_2 (np.ndarray) – Intensity values for the y-axis.

    - max (float) – Maximum value for the bin edges.

    - cmap (matplotlib.colors.Colormap, optional) – Colormap for the histogram.

    - bins (int, optional) – Number of bins for the histogram.

    - colors (list of str, optional) – List of colors for different intensity groups.

    - color (str, optional) – Single color to use if colors is not provided.

    - plot_center_coords (list of tuple, optional) – List of center coordinates to plot as circles.

    - black_background (bool, optional) – Whether to use a black background in the plot.

    - **kwargs (dict) – Additional keyword arguments passed to the plotting functions.

encoding_information.plot_utils.add_multiple_colorbars(ax, cmaps)

  Add multiple colorbars to the given axis, each corresponding to a different colormap.

  Parameters:

    - ax (matplotlib.axes.Axes) – The axis on which the colorbars will be added.

    - cmaps (list of matplotlib.colors.Colormap) – List of colormaps to add colorbars for.

## Classes

class encoding_information.plot_utils.OverlayedHistograms(ax=None, bins=None, num_bins=50, log=True, logx=True)

  Bases: `object`

  Class for plotting multiple histograms on the same axis with equal bin sizes.

  ax

    Axis to plot the histograms on.

    Type:

      matplotlib.axes.Axes

  bins

    Bin edges for the histograms.

    Type:

      np.ndarray or None

  num_bins

    Number of bins for the histograms.

    Type:

      int

  log

    Whether to use a logarithmic scale for the y-axis.

    Type:

      bool

  logx

    Whether to use a logarithmic scale for the x-axis.

    Type:

      bool

  add(values, label=None)

    Add a set of values to the histogram.

    Parameters:

      - values (np.ndarray) – The values to be added to the histogram.

      - label (str, optional) – The label for the values.

  generate_bins()

    Generate logarithmic or linear bin edges based on the values added.

  get_hist_counts(eigenvalues)

    Get the histogram counts for a set of eigenvalues.

    Parameters:

      eigenvalues (np.ndarray) – Eigenvalues to compute the histogram counts for.

  plot(zorder=None, bottom=0.5, **kwargs)

    Plot the histograms on the axis.

    Parameters:

      - zorder (dict, optional) – Order in which to plot the histograms.

      - bottom (float, optional) – Baseline value for the histogram bars.

      - **kwargs (dict) – Additional keyword arguments passed to the bar plot.