epyr.eprplot
Simple plotting module for EPR data from eprload.
This module provides simple plotting functions for data obtained with eprload(): - plot_1d: Plot 1D EPR spectra - plot_2d_map: Plot 2D data as color map - plot_2d_waterfall: Plot 2D data as waterfall plot
Based on the _plot_data function from eprload.py
Functions
|
Plot 1D EPR data. |
|
Plot 2D EPR data as a color map. |
|
Interactive 2D EPR data slicer with a slider control. |
|
Plot 2D EPR data as a waterfall plot. |
- epyr.eprplot.plot_1d(x, y, params=None, title=None, ax=None)[source]
Plot 1D EPR data.
- Parameters:
x (np.ndarray, list, or None) – X-axis data from eprload. Falls back to point index if None or shape mismatch.
y (np.ndarray) – 1D EPR signal array.
params (dict, optional) – Parameter dictionary from eprload, used to extract axis labels and units.
title (str, optional) – Plot title.
ax (matplotlib.axes.Axes, optional) – Axes to draw on. A new figure is created if not provided.
- Returns:
fig (matplotlib.figure.Figure)
ax (matplotlib.axes.Axes)
- Return type:
Examples
>>> from epyr import eprload, plot_1d >>> x, y, params, _ = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC") >>> fig, ax = plot_1d(x, y, params, title="CaWO4:Er, 5 K")
Reuse an existing axes (subplot composition):
>>> import matplotlib.pyplot as plt >>> fig, axes = plt.subplots(1, 2) >>> plot_1d(x, y, params, ax=axes[0])
- epyr.eprplot.plot_2d_map(x, y, params=None, title=None, ax=None, cmap='magma', vmin=None, vmax=None)[source]
Plot 2D EPR data as a color map.
- Parameters:
x (np.ndarray, list, or None) – Axis data from eprload. A list of two arrays sets both x and y axes.
y (np.ndarray) – 2D EPR signal array, shape (ny, nx).
params (dict, optional) – Parameter dictionary from eprload, used to extract axis labels and units.
title (str, optional) – Plot title.
ax (matplotlib.axes.Axes, optional) – Axes to draw on. A new figure is created if not provided.
cmap (str, optional) – Matplotlib colormap name (default: “magma”).
vmin (float, optional) – Lower bound of the color scale. Defaults to data minimum.
vmax (float, optional) – Upper bound of the color scale. Defaults to data maximum.
- Returns:
fig (matplotlib.figure.Figure)
ax (matplotlib.axes.Axes)
- Return type:
Examples
>>> fig, ax = plot_2d_map(x, y, params, vmin=-100, vmax=100) >>> fig, ax = plot_2d_map(x, y, params, vmin=0) # clip negatives
- epyr.eprplot.plot_2d_waterfall(x, y, params=None, title=None, ax=None, offset_factor=0.5, max_traces=20, cmap='viridis', lw=0.75, clip_factor=None)[source]
Plot 2D EPR data as a waterfall plot.
- Parameters:
x (np.ndarray, list, or None) – Axis data from eprload. A list of two arrays sets both x and y axes.
y (np.ndarray) – 2D EPR signal array, shape (ny, nx).
params (dict, optional) – Parameter dictionary from eprload, used to extract axis labels and units.
title (str, optional) – Plot title.
ax (matplotlib.axes.Axes, optional) – Axes to draw on. A new figure is created if not provided.
offset_factor (float, optional) – Vertical spacing between traces as a fraction of the total data range (default: 0.5).
max_traces (int, optional) – Maximum number of traces to display. If ny > max_traces, traces are subsampled uniformly (default: 20).
cmap (str, optional) – Matplotlib colormap used to color-code traces (default: “viridis”).
lw (float, optional) – Line width for each trace (default: 0.75).
clip_factor (float, optional) – Clip each trace at
clip_factor * max(|trace|)before adding the vertical offset. None disables clipping (default). A value of 0.5 clips at 50% of the trace maximum.
- Returns:
fig (matplotlib.figure.Figure)
ax (matplotlib.axes.Axes)
- Return type:
Examples
>>> from epyr import eprload, plot_2d_waterfall >>> x, y, params, _ = eprload("examples/data/Rabi2D_GdCaWO4_13dB_3057G.DSC") >>> fig, ax = plot_2d_waterfall(x, y, params, max_traces=10)
Tighter spacing with strong clipping (useful for noisy backgrounds):
>>> fig, ax = plot_2d_waterfall(x, y, params, offset_factor=0.2, clip_factor=0.3)
- epyr.eprplot.plot_2d_slicer(x, y, params=None, title=None, slice_direction='horizontal', cmap='magma')[source]
Interactive 2D EPR data slicer with a slider control.
- Parameters:
x (np.ndarray, list, or None) – Axis data from eprload. A list of two arrays sets both x and y axes.
y (np.ndarray) – 2D EPR signal array, shape (ny, nx).
params (dict, optional) – Parameter dictionary from eprload, used to extract axis labels and units.
title (str, optional) – Plot title shown above the active slice panel.
slice_direction ({'horizontal', 'vertical'}, optional) – Axis along which to slice (default: ‘horizontal’).
cmap (str, optional) – Matplotlib colormap name for the overview panel (default: “magma”).
- Returns:
Keys: ‘figure’, ‘ax_main’, ‘ax_overview’, ‘slider’, ‘line’, ‘slice_line’.
- Return type:
Notes
Requires an interactive matplotlib backend. In Jupyter, activate with
%matplotlib widgetor%matplotlib notebookbefore calling.Examples
>>> from epyr import eprload, plot_2d_slicer >>> x, y, params, _ = eprload("examples/data/Rabi2D_GdCaWO4_13dB_3057G.DSC") >>> handles = plot_2d_slicer(x, y, params, slice_direction="vertical") >>> handles["slider"].set_val(50) # programmatic slider control