API Reference

This page contains the API reference for PlotEZ.

Main Plotting Functions

PlotEZ - Mundane plotting made easy.

This module provides simplified plotting functions for common visualization tasks.

plotez.plotez.n_plotter(x_data, y_data, n_rows, n_cols, x_labels=None, y_labels=None, data_labels=None, plot_title=None, subplot_titles=None, is_scatter=False, plot_config=None, figure_kwargs=None)[source]

Plot multiple subplots in a grid with optional customization for each subplot.

Parameters:
  • x_data (ArrayLike | list[ArrayLike]) – List of x-axis data arrays for each subplot.

  • y_data (ArrayLike | list[ArrayLike]) – List of y-axis data arrays for each subplot.

  • n_rows (int) – Number of rows in the subplot grid.

  • n_cols (int) – Number of columns in the subplot grid.

  • x_labels (list[str] | None) – List of labels for the x-axes of each subplot.

  • y_labels (list[str] | None) – List of labels for the y-axes of each subplot.

  • data_labels (list[str] | None) – List of labels for the data series in each subplot.

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

  • subplot_titles (list[str] | None) – Titles for the individual subplots, if required.

  • is_scatter (bool) – If True, plots data as scatter plots; otherwise, plots as line plots.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axes. Passed directly to plt.subplots.

Returns:

A shaped (n_rows, n_cols) array of Matplotlib Axes objects.

Return type:

NDArray

plotez.plotez.plot_density(x_data, x_label='X', y_label='Density', plot_title='Density Plot', data_label=None, hist_config=None, axis=None, figure_kwargs=None)[source]

Plot a density histogram based on the given data and configuration.

Parameters:
  • x_data (ArrayLike) – The data array used for generating the density plot.

  • x_label (str) – The label for the x-axis. Default is “X”.

  • y_label (str) – The label for the y-axis. Default is “Density”.

  • plot_title (str) – The title of the density plot. Default is “Density Plot”.

  • data_label (str | None) – The optional label for the dataset being visualized. Default is None.

  • hist_config (HistogramConfig | dict | None) – The histogram configuration, either as an instance of HistogramConfig, a dictionary, or None. If provided, it is used to configure the histogram and ensures that density=True is set. Default is None.

  • axis (Axes | None) – The Matplotlib Axes object on which to draw the plot. If None, a new set of axes is created. Default is None.

  • figure_kwargs (dict | None) – Optional keyword arguments passed when creating a new Matplotlib figure. These arguments are ignored if an existing axis is provided. Default is None.

Returns:

The Matplotlib Axes on which the density plot was drawn.

Return type:

Axes

plotez.plotez.plot_errorband(x_data, y_data, y_lower=None, y_upper=None, x_label='X', y_label='Y', plot_title='XY ErrorBand', data_label='X vs. Y', line=True, band_config=None, line_config=None, axis=None, figure_kwargs=None)[source]

Plot a line graph with a shaded error band representing uncertainty.

Parameters:
  • x_data (ArrayLike) – The independent variable values to plot.

  • y_data (ArrayLike) – The central values to plot.

  • y_lower (int | float | ArrayLike | None) – The lower bound of the error band. If None, it is inferred as a symmetric reflection of y_upper through y_data. At least one of y_lower or y_upper must be provided.

  • y_upper (int | float | ArrayLike | None) – The upper bound of the error band. If None, it is inferred as a symmetric reflection of y_lower through y_data. At least one of y_lower or y_upper must be provided.

  • x_label (str) – The label for the x-axis.

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

  • plot_title (str) – The title of the plot.

  • data_label (str) – The label for the data series, used in the legend. If line=True, the label is attached to the line. If line=False, it is attached to the band.

  • line (bool) – Whether to draw a line through the central values over the error band.

  • band_config (ErrorBandConfig | None) – Configuration for the error band styling. If None, defaults are used.

  • line_config (LinePlotConfig | dict | None) – Configuration for the line styling. If None, defaults are used.

  • axis (Axes | None) – Pre-existing Matplotlib axes to draw on. If provided, figure_kwargs is ignored.

  • figure_kwargs (dict | None) – Keyword arguments passed to plt.subplots when creating a new figure. Ignored if axis is provided.

Returns:

The Matplotlib Axes on which the plot was drawn.

Return type:

Axes

Raises:

ConfigurationError – If both y_lower and y_upper are None.

plotez.plotez.plot_errorband_relative(x_data, y_data, y_lower=None, y_upper=None, x_label='X', y_label='Y', plot_title='XY ErrorBand', data_label='X vs. Y', line=True, band_config=None, line_config=None, axis=None, figure_kwargs=None)[source]

Plot a line graph with a shaded error band using relative (offset) errors.

A convenience wrapper around plot_errorband() where y_lower and y_upper are interpreted as offsets from y_data rather than absolute bounds. Internally, the absolute bounds are computed as y_data - y_lower and y_data + y_upper before passing to plot_errorband().

Parameters:
  • x_data (ArrayLike) – The independent variable values to plot.

  • y_data (ArrayLike) – The central values to plot.

  • y_lower (int | float | ArrayLike | None) – The downward offset from y_data defining the lower band edge. If None, it is inferred as equal to y_upper, implying a symmetric band. At least one of y_lower or y_upper must be provided.

  • y_upper (int | float | ArrayLike | None) – The upward offset from y_data defining the upper band edge. If None, it is inferred as equal to y_lower, implying a symmetric band. At least one of y_lower or y_upper must be provided.

  • x_label (str) – The label for the x-axis.

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

  • plot_title (str) – The title of the plot.

  • data_label (str) – The label for the data series, used in the legend. If line=True, the label is attached to the line. If line=False, it is attached to the band.

  • line (bool) – Whether to draw a line through the central values over the error band.

  • band_config (ErrorBandConfig | None) – Configuration for the error band styling. If None, defaults are used.

  • line_config (LinePlotConfig | dict | None) – Configuration for the line styling. If None, defaults are used.

  • axis (Axes | None) – Pre-existing Matplotlib axes to draw on. If provided, figure_kwargs is ignored.

  • figure_kwargs (dict | None) – Keyword arguments passed to plt.subplots when creating a new figure. Ignored if axis is provided.

Returns:

The Matplotlib Axes on which the plot was drawn.

Return type:

Axes

Raises:

ConfigurationError – If both y_lower and y_upper are None.

See also

plot_errorband

The absolute-bounds version of this function.

plotez.plotez.plot_errorbar(x_data, y_data, x_err=None, y_err=None, x_label='X', y_label='Y', plot_title='XY ErrorBar', data_label='X vs. Y', errorbar_config=None, axis=None, figure_kwargs=None)[source]

Plot an error bar graph with optional error ranges, labels, and configurations.

Parameters:
  • x_data (ArrayLike) – The x-coordinates of the data points.

  • y_data (ArrayLike) – The y-coordinates of the data points.

  • x_err (int | float | ArrayLike | None) – Error margins for x-coordinates. Can be: - Scalar: symmetric error for all points - 1D array (N,): symmetric errors, one per point - 2D array (2, N): asymmetric [lower_errors, upper_errors]

  • y_err (int | float | ArrayLike | None) – Error margins for y-coordinates. Can be: - Scalar: symmetric error for all points - 1D array (N,): symmetric errors, one per point - 2D array (2, N): asymmetric [lower_errors, upper_errors]

  • x_label (str) – The label for the x-axis.

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

  • plot_title (str) – The title of the plot.

  • data_label (str) – The label for the data points, which will appear in the plot legend. If None, the legend is not displayed.

  • errorbar_config (ErrorPlotConfig | None) – Custom configurations for the error bars. If None, default configurations are used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

  • axis (Axes | None) – A matplotlib Axes object on which the plot will be rendered. If None, a new subplot is created using figure_kwargs.

Returns:

The Matplotlib Axes on which the plot was drawn.

Return type:

Axes

plotez.plotez.plot_hist(x_data, x_label='X', y_label='Counts', plot_title='Histogram', data_label=None, hist_config=None, axis=None, figure_kwargs=None)[source]

Plot a histogram of the data.

Parameters:
  • x_data (ArrayLike) – Array or sequence of data points to be histogrammed.

  • x_label (str) – Label for the x-axis.

  • y_label (str) – Label for the y-axis.

  • plot_title (str) – Title for the plot.

  • data_label (str | None) – Label(s) for the data series. This is used in plot’s legend generation.

  • hist_config (HistogramConfig | dict | None) – Configuration object for histogram styling. If None, default configurations are used.

  • axis (Axes | None) – An existing matplotlib axis object on which to plot. If None, a new figure and axis are created.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

Returns:

The Matplotlib Axes on which the histogram was drawn.

Return type:

Axes

plotez.plotez.plot_two_column_file(file_name, delimiter=',', skip_header=False, x_label='X', y_label='Y', data_label='XY Data', plot_title='XY Plot', is_scatter=False, plot_config=None, figure_kwargs=None, axis=None)[source]

Read a two-column file (x, y) and plot the data.

Parameters:
  • file_name (str) – The path to the file to be plotted. The file should contain two columns (x and y data).

  • delimiter (str) – The delimiter used in the file (default is ‘,’).

  • skip_header (bool) – If True, skips the first row in the given data file, otherwise does nothing. Default is False.

  • x_label (str) – The label for the x-axis.

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

  • data_label (str) – Data label for the plot to put in the legend. Defaults to ‘X vs Y’.

  • plot_title (str) – The title for the plot.

  • is_scatter (bool) – If True, creates a scatter plot. Otherwise, creates a line plot. Default is False.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

  • axis (Axes | None) – The axis object to draw the plots on. If not passed, a new axis object will be created internally.

Returns:

The axes object of the plot.

Return type:

Axes

Raises:

ColumnCountError – If the file does not contain exactly two columns.

plotez.plotez.plot_with_dual_axes(x1_data, y1_data, x2_data=None, y2_data=None, x1y1_label='X$_1$ vs. Y$_1$', x1y2_label='X$_1$ vs. Y$_2$', x2y1_label='X$_2$ vs. Y$_1$', use_twin_x=False, axis_labels=None, plot_title='DualAxesPlot', is_scatter=False, plot_config=None, figure_kwargs=None, axis=None)[source]

Plot the data with options for dual axes (x or y) or single axis.

Parameters:
  • x1_data (ArrayLike) – Data for the primary x-axis.

  • y1_data (ArrayLike) – Data for the primary y-axis.

  • x2_data (ArrayLike | None) – Data for the secondary x-axis (used for dual x-axis plots).

  • y2_data (ArrayLike | None) – Data for the secondary y-axis (used for dual y-axis plots).

  • x1y1_label (str) – Label for the plot of X1 vs. Y1.

  • x1y2_label (str) – Label for the plot of X1 vs. Y2 (when using dual Y-axes).

  • x2y1_label (str) – Label for the plot of X2 vs. Y1 (when using dual X-axes).

  • use_twin_x (bool) – If True, creates a dual y-axis plot. If False, creates a dual x-axis plot. Default is False.

  • axis_labels (list[str] | tuple[str, ...] | None) – List of axis labels in the form [x_label, y_label1, y_label2]. Defaults to ["X", r"Y$_1$", r"Y$_2$"] when not provided. Passing a mutable list is deprecated; use a tuple instead.

  • plot_title (str) – Title of the plot.

  • is_scatter (bool) – If True, creates scatter plot; otherwise, line plot. Default is False.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

  • axis (Axes | None) – The axis object to draw the plots on. If not passed, a new axis object will be created internally.

Returns:

A tuple of (primary_axis, secondary_axis) when dual axes are used, otherwise a single Axes.

Return type:

tuple[Axes, Axes] or Axes

plotez.plotez.plot_xxy(x1_data, x2_data, y_data, y_label='Y', x1_label='X$_1$', x2_label='X$_2$', data_labels=None, plot_title='', is_scatter=False, plot_config=None, figure_kwargs=None, axis=None)[source]

Plot two sets of x-data (x1_data and x2_data) against the same y-data (y_data) on the same plot.

Parameters:
  • x1_data (ArrayLike) – The first set of x-axis data to be plotted against y_data.

  • x2_data (ArrayLike) – The second set of x-axis data to be plotted against y_data.

  • y_data (ArrayLike) – The y-axis data for both plots.

  • x1_label (str) – The label for the first x-axis.

  • x2_label (str) – The label for the second x-axis.

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

  • plot_title (str) – The title for the plot.

  • data_labels (list[str] | tuple[str, ...] | None) – The labels for the two datasets. Default is (r"Y vs. X$_1$", r"Y vs. X$_2$"). Passing a mutable list is deprecated; use a tuple instead.

  • is_scatter (bool) – Whether to create a scatter plot (True) or a line plot (False). Default is False.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

  • axis (Axes | None) – A Matplotlib axis to plot on. If None, a new axis is created. Default is None.

Returns:

A tuple of (primary_axis, secondary_axis) for the dual x-axis plot.

Return type:

tuple[Axes, Axes]

plotez.plotez.plot_xy(x_data, y_data, x_label='X', y_label='Y', data_label='XY Data', plot_title='XY Plot', is_scatter=False, plot_config=None, figure_kwargs=None, axis=None)[source]

Plot the x_data against y_data with customizable options.

Parameters:
  • x_data (ArrayLike) – The data for the x-axis.

  • y_data (ArrayLike) – The data for the y-axis.

  • x_label (str) – The label for the x-axis.

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

  • plot_title (str) – The title for the plot.

  • data_label (str) – Data label for the plot to put in the legend.

  • is_scatter (bool) – If True, creates a scatter plot. Otherwise, creates a line plot. Default is False.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

  • axis (Axes | None) – The axis object to draw the plots on. If not passed, a new axis object will be created internally.

Returns:

The axes object of the plot.

Return type:

Axes

plotez.plotez.plot_xyy(x_data, y1_data, y2_data, x_label='X', y1_label='Y$_1$', y2_label='Y$_2$', data_labels=None, plot_title='XYY Plot', is_scatter=False, plot_config=None, figure_kwargs=None, axis=None)[source]

Plot two sets of y-data (y1_data and y2_data) against the same x-data (x_data) on the same plot.

Parameters:
  • x_data (ArrayLike) – The x-axis data for both plots.

  • y1_data (ArrayLike) – The first set of y-axis data to be plotted against x_data.

  • y2_data (ArrayLike) – The second set of y-axis data to be plotted against x_data.

  • x_label (str) – The label for the x-axis.

  • y1_label (str) – The label for the first y-axis.

  • y2_label (str) – The label for the second y-axis.

  • plot_title (str) – The title for the plot.

  • data_labels (list[str] | tuple[str, ...] | None) – The labels for the two datasets. Default is (r"X vs. Y$_1$", r"X vs. Y$_2$"). Passing a mutable list is deprecated; use a tuple instead.

  • is_scatter (bool) – Whether to create a scatter plot (True) or a line plot (False). Default is False.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axis when axis is not provided. Ignored if axis is provided.

  • axis (Axes | None) – A Matplotlib axis to plot on. If None, a new axis is created. Default is None.

Returns:

A tuple of (primary_axis, secondary_axis) for the dual y-axis plot.

Return type:

tuple[Axes, Axes]

plotez.plotez.two_subplots(x_data, y_data, x_labels=None, y_labels=None, data_labels=None, plot_title='TwoSubPlots', subplot_titles=None, orientation='h', is_scatter=False, plot_config=None, figure_kwargs=None)[source]

Create two subplots arranged horizontally or vertically, with optional customization.

Parameters:
  • x_data (ArrayLike | list[ArrayLike]) – List containing x-axis data arrays for each subplot.

  • y_data (ArrayLike | list[ArrayLike]) – List containing y-axis data arrays for each subplot.

  • x_labels (list[str] | tuple[str, ...] | None) – List of labels for the x-axes in each subplot. Defaults to [r"X$_1$", r"X$_2$"]. Passing a mutable list is deprecated; use a tuple instead.

  • y_labels (list[str] | tuple[str, ...] | None) – List of labels for the y-axes in each subplot. Defaults to [r"Y$_1$", r"Y$_2$"]. Passing a mutable list is deprecated; use a tuple instead.

  • data_labels (list[str] | tuple[str, ...] | None) – List of labels for the data series in each subplot. Defaults to [r"X$_1$ vs. Y$_1$", r"X$_2$ vs. Y$_2$"]. Passing a mutable list is deprecated; use a tuple instead.

  • plot_title (str) – Title of the plot.

  • subplot_titles (list[str] | tuple[str, ...] | None) – Titles for the individual subplots, if required. Passing a mutable list is deprecated; use a tuple instead.

  • orientation (str) – Orientation of the subplots, either 'h' for horizontal or 'v' for vertical.

  • is_scatter (bool) – If True, plots data as scatter plots; otherwise, plots as line plots.

  • plot_config (LinePlotConfig | ScatterPlotConfig | None) – Configuration object for line or scatter styling. If None, a default LinePlotConfig is used.

  • figure_kwargs (dict | None) – Keyword arguments for creating the figure and axes. Passed directly to plt.subplots.

Returns:

A shaped (n_rows, n_cols) array of Matplotlib Axes objects.

Return type:

NDArray

Raises:

OrientationError – If orientation is not 'h' or 'v'.

Utility Classes

Parameter Classes

class plotez.backend.utilities.LinePlotConfig(color=None, linewidth=None, linestyle=None, alpha=None, marker=None, markersize=None, markerfacecolor=None, markeredgecolor=None, markeredgewidth=None, _extra=<factory>)[source]

Bases: object

Configuration class for line plots.

Parameters:
__repr__()[source]

Pretty repr showing both explicit and extra params.

get_dict()[source]

Get all parameters as dict for matplotlib.

Return type:

dict[str, Any]

classmethod populate(dictionary)[source]

Create a LinePlotConfig instance from a dictionary, using a mapping for shorthand keys.

Parameters:

dictionary (dict[str, Any])

Return type:

LinePlotConfig

alpha: int | float | list[int | float] | None = None
color: str | list[str] | None = None
linestyle: str | list[str] | None = None
linewidth: int | float | list[int | float] | None = None
marker: str | list[str] | None = None
markeredgecolor: str | list[str] | None = None
markeredgewidth: int | float | list[int | float] | None = None
markerfacecolor: str | list[str] | None = None
markersize: int | float | list[int | float] | None = None
class plotez.backend.utilities.ErrorPlotConfig(color=None, linewidth=None, linestyle=None, alpha=None, ecolor=None, elinewidth=None, marker=None, markersize=None, markerfacecolor=None, markeredgecolor=None, capsize=None, capthick=None, errorevery=None, _extra=<factory>)[source]

Bases: object

Configuration class for error bar plots.

Parameters:
__repr__()[source]

Pretty repr showing both explicit and extra params.

get_dict()[source]

Get all parameters as dict for matplotlib.

Return type:

dict[str, Any]

classmethod populate(dictionary)[source]

Create an ErrorPlotConfig instance from a dictionary, using a mapping for shorthand keys.

Parameters:

dictionary (dict[str, Any])

Return type:

ErrorPlotConfig

alpha: int | float | None = None
capsize: int | float | None = None
capthick: int | float | None = None
color: str | None = None
ecolor: str | None = None
elinewidth: int | float | None = None
errorevery: int | tuple | None = None
linestyle: str | None = None
linewidth: int | float | None = None
marker: str | None = None
markeredgecolor: str | None = None
markerfacecolor: str | None = None
markersize: int | float | None = None
class plotez.backend.utilities.ErrorBandConfig(color=None, alpha=0.25, linewidth=None, edgecolor=None, linestyle=None, hatch=None, interpolate=None, step=None, _extra=<factory>)[source]

Bases: object

Configuration class for error bands (shaded fill regions).

Parameters:
__repr__()[source]

Return a string representation of the ErrorBandConfig instance.

get_dict()[source]

Get all parameters as dict for matplotlib.

Return type:

dict[str, Any]

classmethod populate(dictionary)[source]

Create an ErrorBandConfig instance from a dictionary, using a mapping for shorthand keys.

Parameters:

dictionary (dict[str, Any])

Return type:

ErrorBandConfig

alpha: int | float | list[int | float] = 0.25
color: str | list[str] | None = None
edgecolor: str | list[str] | None = None
hatch: Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'] | list[Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']] | None = None
interpolate: bool | None = None
linestyle: str | list[str] | None = None
linewidth: int | float | list[int | float] | None = None
step: str | Literal['pre', 'post', 'mid'] | None = None
class plotez.backend.utilities.ScatterPlotConfig(color=None, s=None, alpha=None, marker=None, cmap=None, edgecolors=None, facecolors=None, _extra=<factory>)[source]

Bases: object

Configuration class for scatter plots.

Parameters:
__repr__()[source]

Pretty repr showing both explicit and extra params.

get_dict()[source]

Get all parameters as dict for matplotlib.

Return type:

dict[str, Any]

classmethod populate(dictionary)[source]

Create a ScatterPlotConfig instance from a dictionary, using a mapping for shorthand keys.

Parameters:

dictionary (dict[str, Any])

Return type:

ScatterPlotConfig

alpha: int | float | list[int | float] | None = None
cmap: str | list[str] | None = None
color: str | list[str] | None = None
edgecolors: str | list[str] | None = None
facecolors: str | list[str] | None = None
marker: str | list[str] | None = None
s: int | float | list[int | float] | None = None
class plotez.backend.utilities.HistogramConfig(bins=None, density=None, histtype=None, color=None, alpha=None, edgecolor=None, facecolor=None, linewidth=None, orientation=None, cumulative=None, hatch=None, _extra=<factory>)[source]

Bases: object

Configuration class for histogram plots.

Parameters:
  • bins (int | None)

  • density (bool | None)

  • histtype (str | None)

  • color (str | None)

  • alpha (int | float | None)

  • edgecolor (str | None)

  • facecolor (str | None)

  • linewidth (int | float | None)

  • orientation (str | None)

  • cumulative (bool | None)

  • hatch (Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'] | None)

  • _extra (dict[str, Any])

__repr__()[source]

Pretty repr showing both explicit and extra params.

get_dict()[source]

Get all parameters are dict for matplotlib.

Return type:

dict[str, Any]

classmethod populate(dictionary)[source]

Create a HistogramConfig instance from a dictionary, using a mapping for shorthand keys.

Parameters:

dictionary (dict[str, Any])

alpha: int | float | None = None
bins: int | None = None
color: str | None = None
cumulative: bool | None = None
density: bool | None = None
edgecolor: str | None = None
facecolor: str | None = None
hatch: Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'] | None = None
histtype: str | None = None
linewidth: int | float | None = None
orientation: str | None = None

Utility Functions

plotez.backend.utilities.plot_or_scatter(axes, scatter)[source]

Return the plot or scatter method based on the specified plot type.

Parameters:
  • axes – The matplotlib axis on which to apply the plot or scatter method.

  • scatter (bool) – If True, returns the scatter method; otherwise, returns the plot method.

Returns:

The matplotlib plotting method (axes.scatter if scatter is True, otherwise axes.plot).

Return type:

function

plotez.backend.utilities.split_dictionary(plot_instance)[source]

Split a config instance’s parameters into two separate instances.

Parameters:

plot_instance (LSE) – An instance with parameters stored as lists or tuples. Each parameter should be a list or tuple containing exactly two values, corresponding to settings for the two resulting instances.

Returns:

Two instances of the same type as plot_instance, with parameters split based on the values in plot_instance. The first instance (instance1) and second instance (instance2) will have their attributes set according to the first and second elements, respectively, from each list or tuple in plot_instance.

Return type:

Tuple

Raises:

ValueError – If any parameter in plot_instance is not a list or tuple with exactly two elements.

Notes

The parameters with only one element are broadcast to both instances rather than raising an error.

plotez.backend.utilities.dual_axes_data_validation(x1_data, x2_data, y1_data, y2_data, use_twin_x, axis_labels)[source]

Validate the data and parameters for dual-axes plotting.

Parameters:
  • x1_data (ArrayLike) – Data for the primary x-axis.

  • x2_data (ArrayLike | None) – Data for the secondary x-axis (used in dual x-axis plots). Should be None if use_twin_x is True.

  • y1_data (ArrayLike) – Data for the primary y-axis.

  • y2_data (ArrayLike | None) – Data for the secondary y-axis (used in dual y-axis plots). Should be None if use_twin_x is False.

  • use_twin_x (bool) – If True, a dual y-axis plot is expected; otherwise, a dual x-axis plot is expected.

  • axis_labels (list[str | None]) – List of axis labels. Must have exactly three elements: - Label for the x-axis of the primary plot. - Label for the y-axis of the primary plot. - Label for the secondary axis (x or y).

Raises:
Return type:

tuple[NDArray, NDArray, NDArray | None, NDArray | None]

Convenience / Wrapper Functions

These factory functions provide a concise, keyword-driven way to build config objects without importing the dataclass names directly. All are available at the top-level plotez namespace.

Each function also has a short alias that can be used interchangeably:

Long-form function

Short alias

line_plot_configuration

lpc

error_plot_configuration

epc

error_band_configuration

ebc

scatter_plot_configuration``| ``spc

histogram_config

hgc

plotez.backend._wrappers.line_plot_configuration(c=None, lw=None, ls=None, alpha=None, marker=None, ms=None, mfc=None, mec=None, mew=None, **kwargs)[source]

Create a configuration object for line plots.

Parameters:
  • c (str | list[str] | None) – Line color.

  • lw (int | float | list[int | float] | None) – Line width.

  • ls (str | list[str] | None) – Line style (e.g., ‘-’, ‘–’, ‘-.’, ‘:’).

  • alpha (int | float | list[int | float] | None) – Transparency level (0.0 to 1.0).

  • marker (str | list[str] | None) – Marker style (e.g., ‘o’, ‘s’, ‘^’).

  • ms (int | float | list[int | float] | None) – Marker size.

  • mfc (str | list[str] | None) – Marker face color.

  • mec (str | list[str] | None) – Marker-edge color.

  • mew (int | float | list[int | float] | None) – Marker-edge width.

  • **kwargs – Additional keyword arguments passed to the underlying plot function.

Returns:

Configuration object for line plots.

Return type:

LinePlotConfig

plotez.backend._wrappers.error_plot_configuration(c=None, lw=None, ls=None, alpha=None, ecolor=None, elinewidth=None, marker=None, ms=None, mfc=None, mec=None, capsize=None, capthick=None, errorevery=None, **kwargs)[source]

Create a configuration object for error bar plots.

Parameters:
  • c (str | None) – Line color.

  • lw (int | float | None) – Line width.

  • ls (str | None) – Line style (e.g., ‘-’, ‘–’, ‘-.’, ‘:’).

  • alpha (int | float | None) – Transparency level (0.0 to 1.0).

  • ecolor (str | None) – Error bar color.

  • elinewidth (int | float | None) – Error bar line width.

  • marker (str | None) – Marker style (e.g., ‘o’, ‘s’, ‘^’).

  • ms (int | float | None) – Marker size.

  • mfc (str | None) – Marker face color.

  • mec (str | None) – Marker edge color.

  • capsize (int | float | None) – Length of the error bar caps in points.

  • capthick (int | float | None) – Thickness of error bar caps.

  • errorevery (int | tuple | None) – Draw error bars on a subset of data points.

  • **kwargs – Additional keyword arguments passed to the underlying errorbar function.

Returns:

Configuration object for error bar plots.

Return type:

ErrorPlotConfig

plotez.backend._wrappers.error_band_configuration(c=None, alpha=0.25, lw=None, ec=None, ls=None, hatch=None, interpolate=None, step=None, **kwargs)[source]

Create a configuration object for error bands.

Parameters:
  • c (str | None) – Fill color for the error band.

  • alpha (int | float) – Transparency level (0.0 to 1.0).

  • lw (int | float | None) – Edge line width.

  • ec (str | None) – Edge color.

  • ls (str | None) – Edge line style (e.g., ‘-’, ‘–’, ‘-.’, ‘:’).

  • hatch (Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'] | list[~typing.Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*']] | None) – Hatching pattern (e.g., ‘/’, ‘|’, ‘-’, ‘+’, ‘x’).

  • interpolate (bool | None) – Whether to interpolate the error band.

  • step (str | Literal['pre', 'post', 'mid'] | None) – Step mode for the band (e.g., ‘pre’, ‘post’, ‘mid’).

  • **kwargs – Additional keyword arguments passed to the underlying fill function.

Returns:

Configuration object for error bands.

Return type:

ErrorBandConfig

plotez.backend._wrappers.scatter_plot_configuration(c=None, s=None, alpha=None, marker=None, cmap=None, ec=None, fc=None, **kwargs)[source]

Create a configuration object for scatter plots.

Parameters:
  • c (str | list[str] | None) – Marker color(s).

  • s (int | float | list[int | float] | None) – Marker size(s) in points squared.

  • alpha (int | float | list[int | float] | None) – Transparency level (0.0 to 1.0).

  • marker (str | list[str] | None) – Marker style (e.g., ‘o’, ‘s’, ‘^’).

  • cmap (str | list[str] | None) – Colormap name or object.

  • ec (str | list[str] | None) – Edge color(s).

  • fc (str | list[str] | None) – Face color(s).

  • **kwargs – Additional keyword arguments passed to the underlying scatter function.

Returns:

Configuration object for scatter plots.

Return type:

ScatterPlotConfig

plotez.backend._wrappers.histogram_config(bins=None, density=None, histtype=None, color=None, alpha=None, edgecolor=None, facecolor=None, linewidth=None, orientation=None, cumulative=None, hatch=None, **kwargs)[source]

Create a HistogramConfig instance with the given parameters.

Parameters:
  • bins (int | None)

  • density (bool | None)

  • histtype (str | None)

  • color (str | None)

  • alpha (int | float | None)

  • edgecolor (str | None)

  • facecolor (str | None)

  • linewidth (int | float | None)

  • orientation (str | None)

  • cumulative (bool | None)

  • hatch (Literal['/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'] | None)

Shorthand Key Reference

All populate() class methods and wrapper functions accept shorthand aliases in place of full matplotlib parameter names. The tables below list every recognised alias.

Line / Error-bar parameters

Alias

Full parameter name

ls

linestyle

lw

linewidth

c

color

ms

markersize

mec

markeredgecolor

mfc

markerfacecolor

mew

markeredgewidth

Error-bar-only parameters

The ErrorPlotConfig / epc wrapper also accepts all line aliases above, plus:

Alias

Full parameter name

ecolor

ecolor

elinewidth

elinewidth

capsize

capsize

capthick

capthick

Scatter parameters

Alias

Full parameter name

c

color

s

size

ec

edgecolors

fc

facecolors

Error band parameters

The ErrorBandConfig / ebc wrapper accepts the following shorthand aliases:

Alias

Full parameter name

c

color

ec

edgecolor

lw

linewidth

ls

linestyle

hatch, interpolate, and step are passed through under their own names.

Histogram parameters

The HistogramConfig / hgc wrapper accepts the following shorthand aliases (via populate() and the hgc factory function):

Alias

Full parameter name

c

color

lw

linewidth

ec

edgecolor

bins, density, histtype, alpha, facecolor, orientation, cumulative, and hatch are passed through under their own names.

Error Handling

PlotEZ Error Handling.

Custom exceptions for plotting operations.

exception plotez.backend.error_handling.AxisLabelError[source]

Bases: ConfigurationError

Raised when the axis_labels sequence does not contain exactly three elements.

Notes

Dual-axes functions require labels for three axes: primary x, primary y, and the secondary axis (either x or y).

exception plotez.backend.error_handling.ColumnCountError[source]

Bases: DataError

Raised when a data file does not contain exactly two columns.

Notes

plot_two_column_file expects files with exactly one x-column and one y-column. Any other column count triggers this error.

exception plotez.backend.error_handling.ConfigurationError[source]

Bases: PlotError

Base class for plot configuration and parameter errors.

Notes

Inherit from this class for errors that arise from incorrect or conflicting plot configuration options rather than from the data itself.

exception plotez.backend.error_handling.DataError[source]

Bases: PlotError

Base class for data-related plotting errors.

Notes

Inherit from this class for any error that stems from invalid, malformed, or incompatible input data arrays or files.

exception plotez.backend.error_handling.EmptyDataError[source]

Bases: DataError

Raised when required primary x or y data is empty.

Notes

At least one data point must be present in the primary x and y arrays before a plot can be constructed.

exception plotez.backend.error_handling.OrientationError[source]

Bases: PlotError

Raised when an invalid or unexpected orientation is used in a plot.

Notes

This error occurs when the orientation parameter for a plot is set incorrectly or does not match the expected format.

exception plotez.backend.error_handling.PlotError[source]

Bases: Exception

Base class for exceptions related to plotting operations.

Notes

This serves as the parent class for all plotting-related errors. Specific exceptions related to plot configuration or data issues should inherit from this class.

exception plotez.backend.error_handling.ShapeError[source]

Bases: DataError

Raised when an array has an unexpected or incompatible shape.

Notes

Typically raised when an error array intended for asymmetric error bars does not satisfy the required (2, N) shape contract.

exception plotez.backend.error_handling.TwinXDataError[source]

Bases: ConfigurationError

Is raised when x2_data is supplied for a dual-Y-axis (use_twin_x=True) plot.

Notes

A dual-Y-axis plot shares the x-axis between both datasets; providing a separate x2_data is therefore contradictory and not permitted.

exception plotez.backend.error_handling.TwinYDataError[source]

Bases: ConfigurationError

Is raised when y2_data is supplied for a dual-X-axis (use_twin_x=False) plot.

Notes

A dual-X-axis plot shares the y-axis between both datasets; providing a separate y2_data is therefore contradictory and not permitted.

Type Aliases

Note

AxesFigReturn is deprecated as of v0.3.2 and kept only as a backward-compatible alias for AxesReturn. It will be removed in a future release. Use AxesReturn (Axes | tuple[Axes, Axes] | NDArray) for all new code.

Type aliases used throughout PlotEZ.

Public aliases

Name

Description

NDArray

Re-export of numpy.ndarray but as a typehint – any array-like input accepted by NumPy.

AxesReturn

Axes | tuple[Axes, Axes] | NDArray – unified return type for all plot functions. Single-axis functions return Axes; dual-axis functions return tuple[Axes, Axes]; grid functions (n_plotter, two_subplots) return a shaped NDArray of Axes.