Plotters: visualizing ixdat
data
Source: https://github.com/ixdat/ixdat/tree/user_ready/src/ixdat/plotters
In ixdat
, straightforward plotting of your data is a priority. Here you can find the documentation for the already implemented plotters for different kinds of experimental data. Use the menu on the right for easier navigation between the different sections.
Basic
The base_mpl_plotter
module
Base class for plotters using matplotlib
- class ixdat.plotters.base_mpl_plotter.MPLPlotter[source]
Base class for plotters based on matplotlib. Has methods for making mpl axes.
- new_ax(xlabel=None, ylabel=None, interactive=True)[source]
Return a new matplotlib axis optionally with the given x and y labels
- Parameters
xlabel (str) – The label to apply to the x-axis
ylabel (str) – The label to apply to the y-axis
interactive (bool) – Whether to activate interactive range selection (default True)
- new_three_panel_axes(n_bottom=1, n_middle=1, n_top=1, interactive=True)[source]
Return the axes handles for a bottom, middle, and top panel.
- Parameters
n_top (int) – 1 for a single y-axis, 2 for left and right y-axes on top panel
n_middle (int) – 1 for a single y-axis, 2 for left and right y-axes on middle
n_bottom (int) – 1 for a single y-axis, 2 for left and right y-axes on bottom
interactive (bool) – Whether to activate interactive range selection (default True)
- Returns list of axes: top left, middle left, bottom left(, top right, middle
right, bottom right)
- new_two_panel_axes(n_bottom=1, n_top=1, emphasis='top', interactive=True)[source]
Return the axes handles for a bottom and top panel.
- Parameters
n_top (int) – 1 for a single y-axis, 2 for left and right y-axes on top panel
n_bottom (int) – 1 for a single y-axis, 2 for left and right y-axes on bottom
emphasis (str or None) – “top” for bigger top panel, “bottom” for bigger bottom panel, None for equal-sized panels
interactive (bool) – Whether to activate interactive range selection (default True)
Returns list of axes: top left, bottom left(, top right, bottom right)
The value_plotter
module
Classes for plotting measurement data
- class ixdat.plotters.value_plotter.ValuePlotter(measurement=None)[source]
Default plotter. By default plots all of the VSeries vs time on a single axis
- plot_measurement(measurement=None, v_list=None, tspan=None, ax=None, legend=True, logscale=False)[source]
Plot a measurement’s values vs time
- Parameters
measurement (Measurement) – The measurement to plot
v_list (list of str) – The names of the data series to include. Defaults to names of all VSeries in the measurement.
tspan (timespan) – The timespan to include in the file, defaults to all of it
legend (bool) – Whether to include a legend. Defaults to True.
logscale (bool) – Whether to use a log-scaled y-axis. Defaults to False.
Electrochemistry
The ec_plotter
module
Plotter for Electrochemistry
- class ixdat.plotters.ec_plotter.CVDiffPlotter(measurement=None)[source]
A matplotlib plotter for highlighting the difference between two cv’s.
- plot(measurement=None, ax=None)[source]
Plot the two cycles of the CVDiff measurement and fill in the areas between
example: https://ixdat.readthedocs.io/en/latest/_images/cv_diff.svg
- plot_diff(measurement=None, tspan=None, ax=None)[source]
Plot the difference between the two cv’s vs potential.
The trace is solid where the current in cv_2 is greater than cv_1 in the anodic scan or the current cv_2 is more negative than cv_1 in the cathodic scan.
- class ixdat.plotters.ec_plotter.ECPlotter(measurement=None)[source]
A matplotlib plotter specialized in electrochemistry measurements.
- plot_measurement(*, measurement=None, tspan=None, U_name=None, J_name=None, U_color=None, J_color=None, V_str=None, J_str=None, V_color=None, axes=None, **plot_kwargs)[source]
Plot two variables on two y-axes vs time
All arguments are optional. By default it plots potential in black on the left y-axis and current in red on the right y-axis, using data from its entire measurement. The axes are colored to match the traces and labeled with the respective series names.
- Parameters
measurement (Measurement) – The measurement to plot, if not the one the plotter was initiated with.
tspan (iter of float) – The timespan (wrt to measurement.tstamp) to plot.
axes (list of matplotlib.Axis) – Two axes to plot on, if not the default new twinx()’d axes. axes[0] is for U_name and axes[1] for J_name.
U_name (string) – The name of the ValueSeries to plot on the left y-axis. Defaults to measurement.V_str, which for an ECMeasurement is the name of its most calibrated/correct potential.
J_name (string) – The name of the ValueSeries to plot on the right y-axis. Defaults to measurement.J_str, which for an ECMeasurement is the name of its most normalized/correct current.
U_color (str) – The color to plot U_name. Defaults to black.
J_color (str) – The color to plot J_name. Defaults to red.
V_str (str) – DEPRECATED. Use U_name.
J_str (str) – DEPRECATED. Use J_name.
V_color (str) – DEPRECATED. Use U_color.
**plot_kwargs (dict) – Additional key-word arguments are passed to matplotlib’s plot() function. See below for a few examples
- Keyword Arguments
linestle (str) – Type of line, e.g. “-” for solid or “–” for dotted
Returns list of matplotlib.pyplot.Axis: The axes plotted on.
- plot_vs_potential(measurement=None, tspan=None, U_name=None, J_name=None, ax=None, **plot_kwargs)[source]
Plot an ECMeasurement with electrode potential on the x-axis.
This can actually plot with anything on the x-axis, by specifying what you want on the x-axis using V_str. The y-axis variable, which can be specified by J_str, is interpolated onto the time corresponding to the x-axis variable. .. TODO:
This is a special case of the not-yet-implemented generalized `plot_vs`. Consider an inheritance structure to reduce redundancy in future plotters. sub-TODO: hide or fix TODO's using sphix boxes.
All arguments are optional. By default it will plot current vs potential in black on a single axis for the whole experiment.
TODO: color gradient (cmap=inferno) from first to last cycle.
- Parameters
measurement (Measurement) – What to plot. Defaults to the measurement the plotter was initialized with
tspan (iter of float) – The timespan, relative to vs measurement.tstamp, on which to plot.
U_name (str) – Name of the x-axis variable. Defaults to calibrated potential
J_name (str) – Name of the y-axis variable. Defaults to normalized current.
ax (matplotlib.pyplot.Axis) – The axis to plot on, if not a new one.
**plot_kwargs (dict) – Additional key-word arguments are passed to matplotlib’s plot() function. See below for a few examples
- Keyword Arguments
color (color) – Color of the trace, e.g. “r”, “blue”, or RGB like [0, 0, 1]
linestle (str) – Type of line, e.g. “-” for solid or “–” for dotted
Returns matplotlib.pyplot.axis: The axis plotted on.
Mass Spectrometry
The ms_plotter
module
Plotter for Mass Spectrometry
- class ixdat.plotters.ms_plotter.MSPlotter(measurement=None)[source]
A matplotlib plotter specialized in mass spectrometry MID measurements.
- plot_measurement(*, measurement=None, ax=None, axes=None, mass_list=None, mass_lists=None, mol_list=None, mol_lists=None, tspan=None, tspan_bg=None, remove_background=None, unit=None, x_unit=None, logplot=True, logdata=False, legend=True, **kwargs)[source]
Plot m/z signal vs time (MID) data and return the axis.
- There are four ways to specify what to plot. Only specify one of these::
mass_list: Uncalibrated signals in [(u/n/p)A] on on axis mass_lists: Uncalibrated signals in [(u/n/p)A] on two axes mol_list: Calibrated signals in [(u/n/p)mol/s] on on axis mol_lists: Calibrated signals in [(u/n/p)mol/s] on two axes
Two axes refers to separate left and right y-axes. Default is to use all available masses as mass_list.
- Parameters
measurement (MSMeasurement) – Defaults to the one that initiated the plotter
ax (matplotlib axis) – Defaults to a new axis
axes (list of matplotlib axis) – Left and right y-axes if mass_lists are given
mass_list (list of str) – The names of the m/z values, eg. [“M2”, …] to plot. Defaults to all of them (measurement.mass_list)
mass_lists (list of list of str) – Alternately, two lists can be given for masses in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
mol_list (list of str) – The names of the molecules, eg. [“H2”, …] to plot. Defaults to all of them if quantified (measurement.mass_list)
mol_lists (list of list of str) – Alternately, two lists can be given for molecules in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
tspan (iter of float) – The time interval to plot, wrt measurement.tstamp
tspan_bg (timespan) – A timespan for which to assume the signal is at its background. The average signals during this timespan are subtracted. If mass_lists are given rather than a single mass_list, tspan_bg must also be two timespans - one for each axis. Default is None for no background subtraction.
remove_background (bool) – Whether otherwise to subtract pre-determined background signals if available. Defaults to (not logplot)
unit (str) – unit of the y axis. defaults to “A” or “mol/s”
x_unit (str) – unit of the x axis variable (usually time). defaults to “s”
logplot (bool) – Whether to plot the MS data on a log scale (default True)
logdata (bool) – Whether to plot the natural logarithm of MS data on a linear scale (default False)
legend (bool) – Whether to use a legend for the MS data (default True)
kwargs – extra key-word args are passed on to matplotlib’s plot()
- plot_vs(*, x_name, measurement=None, ax=None, axes=None, mass_list=None, mass_lists=None, mol_list=None, mol_lists=None, tspan=None, tspan_bg=None, remove_background=None, unit=None, x_unit=None, logplot=True, logdata=False, legend=True, **plot_kwargs)[source]
Plot m/z signal (MID) data against a specified variable and return the axis.
- There are four ways to specify what to plot. Only specify one of these::
mass_list: Uncalibrated signals in [(u/n/p)A] on on axis mass_lists: Uncalibrated signals in [(u/n/p)A] on two axes mol_list: Calibrated signals in [(u/n/p)mol/s] on on axis mol_lists: Calibrated signals in [(u/n/p)mol/s] on two axes
Two axes refers to seperate left and right y-axes. Default is to use all available masses as mass_list.
- Parameters
x_name (str) – Name of the variable to plot on the x-axis
measurement (MSMeasurement) – Defaults to the one that initiated the plotter
ax (matplotlib axis) – Defaults to a new axis
axes (list of matplotlib axis) – Left and right y-axes if mass_lists are given
mass_list (list of str) – The names of the m/z values, eg. [“M2”, …] to plot. Defaults to all of them (measurement.mass_list)
mass_lists (list of list of str) – Alternately, two lists can be given for masses in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
mol_list (list of str) – The names of the molecules, eg. [“H2”, …] to plot. Defaults to all of them (measurement.mass_list)
mol_lists (list of list of str) – Alternately, two lists can be given for molecules in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
tspan (iter of float) – The time interval to plot, wrt measurement.tstamp
tspan_bg (timespan) – A timespan for which to assume the signal is at its background. The average signals during this timespan are subtracted. If mass_lists are given rather than a single mass_list, tspan_bg must also be two timespans - one for each axis. Default is None for no background subtraction.
remove_background (bool) – Whether otherwise to subtract pre-determined background signals if available
unit (str) – defaults to “A” or “mol/s”
x_unit (str) – defaults to x_name.unit.name
logplot (bool) – Whether to plot the MS data on a log scale (default True)
logdata (bool) – Whether to plot the natural logarithm of MS data on a linear scale (default False)
legend (bool) – Whether to use a legend for the MS data (default True)
plot_kwargs – additional key-word args are passed on to matplotlib’s plot()
- class ixdat.plotters.ms_plotter.MSSpectroPlotter(measurement=None)[source]
A matplotlib plotter specialized in mass spectrometry MID measurements.
- plot_measurement(*, measurement=None, axes=None, mass_list=None, mass_lists=None, mol_list=None, mol_lists=None, tspan=None, tspan_bg=None, remove_background=None, unit=None, x_unit=None, logplot=True, logdata=False, legend=True, xspan=None, cmap_name='inferno', make_colorbar=False, emphasis='top', ms_data='top', max_threshold=None, min_threshold=None, scanning_mask=None, vmin=None, vmax=None, **kwargs)[source]
Plot m/z signal, mass spectra vs time (MID) data and return the axes of a two panel figure.
- There are four ways to specify what to plot. Only specify one of these::
mass_list: Uncalibrated signals in [(u/n/p)A] on on axis mass_lists: Uncalibrated signals in [(u/n/p)A] on two axes mol_list: Calibrated signals in [(u/n/p)mol/s] on on axis mol_lists: Calibrated signals in [(u/n/p)mol/s] on two axes
Two axes refers to separate left and right y-axes. Default is to use all available masses as mass_list.
- Parameters
measurement (SpectroMSMeasurement) – Defaults to the one that initiated the plotter
axes (list of matplotlib axis) – Left and right y-axes if mass_lists are given default to axes[0] as left and axes[2] as right axis for plotting masses and axes[1] for plotting MSSpectra
mass_list (list of str) – The names of the m/z values, eg. [“M2”, …] to plot. Defaults to all of them (measurement.mass_list)
mass_lists (list of list of str) – Alternately, two lists can be given for masses in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
mol_list (list of str) – The names of the molecules, eg. [“H2”, …] to plot. Defaults to all of them (measurement.mass_list)
mol_lists (list of list of str) – Alternately, two lists can be given for molecules in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
tspan (iter of float) – The time interval to plot, wrt measurement.tstamp
tspan_bg (timespan) – A timespan for which to assume the signal is at its background. The average signals during this timespan are subtracted. If mass_lists are given rather than a single mass_list, tspan_bg must also be two timespans - one for each axis. Default is None for no background subtraction.
remove_background (bool) – Whether otherwise to subtract pre-determined background signals if available. Defaults to (not logplot)
unit (str) – defaults to “A” or “mol/s”
x_unit (str) – defaults to “s”
logplot (bool) – Whether to plot the MS data on a log scale (default True)
logdata (bool) – Whether to plot the natural logarithm of MS data on a linear scale (default False)
legend (bool) – Whether to use a legend for the MS data (default True)
xspan (iter of float) – The physical span for spectra to plot
cmap_name (str) – Colour map to pass to heat_plot method
make_colorbar (bool) – Include a colour bar. Misalignes time axis with other panels in same figure
emphasis (str) – Whether to emphasise top or bottom panel 3/5 fig size or eq.
ms_data (str) – Whether to plot ms_data on “top” or “bottom” panel
max_threshold (int or float) – Only applies to spectra plotted with heat_plot. All values above max threshold is set to 0 (zero).
min_threshold (int or float) – Only applies to spectra plotted with heat_plot. All values below threshold is set to 0 (zero).
scanning_mask (boolean list) – Only applies to spectra plotted with heat_plot. List of booleans of same shape as SpectrumSeries.data to exclude specific data prior to plotting
vmin (int or float) – Shift minimum value in color bar. Default lowest value in measurement.spectrum_series.
vmax (int or float) – Shift maximum value in color bar. Default highest value in measurement.spectrum_series.
kwargs – extra key-word args are passed on to matplotlib’s plot()
- plot_measurement_vs(*, vs_name, measurement=None, axes=None, mass_list=None, mass_lists=None, mol_list=None, mol_lists=None, vspan=None, tspan=None, tspan_bg=None, remove_background=None, unit=None, vs_unit=None, logplot=True, logdata=False, legend=True, xspan=None, cmap_name='inferno', make_colorbar=False, vmin=None, vmax=None, emphasis='top', ms_data='top', max_threshold=None, min_threshold=None, scanning_mask=None, sort_spectra='linear', **kwargs)[source]
Plot m/z signal and MSSpectra data in a two panel subfigure vs a specified variable and return the axes.
There are four ways to specify which (MID) signals to plot in panel. Only specify one of these:
mass_list: Uncalibrated signals in [(u/n/p)A] on on axis mass_lists: Uncalibrated signals in [(u/n/p)A] on two axes mol_list: Calibrated signals in [(u/n/p)mol/s] on on axis mol_lists: Calibrated signals in [(u/n/p)mol/s] on two axes
Two axes refers to separate left and right y-axes. Default is to use all available masses as mass_list.
- Parameters
measurement (SpectroMSMeasurement) – Defaults to the one that initiated the plotter
vs_name (str) – Name of the series to plot versus.
axes (list of matplotlib axis) – Defaults to axes[0], axes[2] for left and right axis for plotting masses and axes[1] for MSSpectra data.
mass_list (list of str) – The names of the m/z values, eg. [“M2”, …] to plot. Defaults to all of them (measurement.mass_list)
mass_lists (list of list of str) – Alternately, two lists can be given for masses in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
mol_list (list of str) – The names of the molecules, eg. [“H2”, …] to plot. Defaults to all of them (measurement.mass_list)
mol_lists (list of list of str) – Alternately, two lists can be given for molecules in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
vspan (iter of float) – The value interval to plot on x_axis
tspan (iter of float) – The time interval to plot, wrt measurement.tstamp
tspan_bg (timespan) – A timespan for which to assume the signal is at its background. The average signals during this timespan are subtracted. If mass_lists are given rather than a single mass_list, tspan_bg must also be two timespans - one for each axis. Default is None for no background subtraction.
remove_background (bool) – Whether otherwise to subtract pre-determined background signals if available. Defaults to (not logplot)
unit (str) – defaults to “A” or “mol/s”
vs_unit (str) – defaults to v_name.unit.name
logplot (bool) – Whether to plot the MS data on a log scale (default True)
logdata (bool) – Whether to plot the natural logarithm of MS data on a linear scale (default False)
legend (bool) – Whether to use a legend for the MS data (default True)
xspan (iter of float) – The physical span for spectra to plot
cmap_name (str) – Colour map to pass to heat_plot method
make_colorbar (bool) – Include a colour bar. Misalignes time axis with other panels in same figure
vmin (int or float) – Shift minimum value in color bar. Default lowest value in measurement.spectrum_series.
vmax (int or float) – Shift maximum value in color bar. Default highest value in measurement.spectrum_series.
emphasis (str) – Whether to emphasise top or bottom panel 3/5 fig size or eq. Default ‘top’
ms_data (str) – Whether to plot ms_data on “top” or “bottom” panel. Default ‘top’
max_threshold (int or float) – Only applies to spectra plotted with heat_plot. All values above max threshold is set to 0 (zero).
min_threshold (int or float) – Only applies to spectra plotted with heat_plot. All values below threshold is set to 0 (zero).
scanning_mask (boolean list) – Only applies to spectra plotted with heat_plot. List of booleans of same shape as SpectrumSeries.data to exclude specific data prior to plotting
sort_spectra (list or str) –
Whether or not to sort the spectra data prior to plotting. There is three specifers:
- ’none’:
This gives no new sorting. Effectively the spectras are sorted by time. (tstamp for each of the spectrum).
- ’linear’ (default):
the spectras are sorted linear to v_name from low to high.
- a list of same shape as field.data to be sorted:
This list is passed directly as the indices to sort the spectras. Defaults to sort lowest to highest value. Example
Note: If tspan spans a time span of a measurement with up and down cycles in v_name, this might yield funny looking heat_plots.
Example: Scanning up and down in temperature from T_low to T_high the spectras obtained wil be plotted from [T_low_start .. T_high .. T_low_end].
If ‘none’ sorting is specified leads to heat_plot xaxis linearly
from T_low_start to T_low_end missing representation of the high values in the middle of the axis.
- If ‘linear’ sorting is specified all spectras obtained
are sorted linearly from lowest v_name_value to highest v_name. When data is assymetric from scanning up or down in v_name this leads to abrupt looking figures since two non similair spectras are obtained at similair v_name value and hence plotted next to eachother.
kwargs – extra key-word args are passed on to matplotlib’s plot()
EC-MS
The ecms_plotter
module
Plotter for Electrochemistry - Mass Spectrometry
- class ixdat.plotters.ecms_plotter.ECMSPlotter(measurement=None)[source]
A matplotlib plotter for EC-MS measurements.
- plot_measurement(*, measurement=None, axes=None, mass_list=None, mass_lists=None, mol_list=None, mol_lists=None, tspan=None, tspan_bg=None, remove_background=None, removebackground=None, unit=None, U_name=None, J_name=None, U_color='k', J_color='r', V_str=None, J_str=None, V_color=None, logplot=None, legend=True, emphasis='top', **kwargs)[source]
Make an EC-MS plot vs time and return the axis handles.
Allocates tasks to ECPlotter.plot_measurement() and MSPlotter.plot_measurement()
- Parameters
measurement (ECMSMeasurement) – Defaults to the measurement to which the plotter is bound (self.measurement)
axes (list of matplotlib axes) – axes[0] plots the MID data, axes[1] the variable given by J_name (potential), and axes[3] the variable given by J_name (current). By default three axes are made with axes[0] a top panel with 3/5 the area, and axes[1] and axes[3] are the left and right y-axes of the lower panel with 2/5 the area. axes[2], typically the top right panel, will only be used if two MS axes are requested (see mass_lists and mol_lists).
mass_list (list of str) – The names of the m/z values, eg. [“M2”, …] to plot. Defaults to all of them (measurement.mass_list)
mass_lists (list of list of str) – Alternately, two lists can be given for masses in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
mol_list (list of str) – The names of the molecules, eg. [“H2”, …] to plot. Defaults to all of them (measurement.mass_list)
mol_lists (list of list of str) – Alternately, two lists can be given for molecules in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
tspan (str or iter of float) – The time interval (t_start, t_end) to plot, wrt measurement.tstamp. Use tspan=”all” to plot all the data. Defaults to EC data tspan. See :fun:`determine_tspan`_ for more details.
tspan_bg (timespan) – A timespan for which to assume the signal is at its background. The average signals during this timespan are subtracted. If mass_lists are given rather than a single mass_list, tspan_bg must also be two timespans - one for each axis. Default is None for no background subtraction.
remove_background (bool) – Whether otherwise to subtract pre-determined background signals if available. Defaults to (not logplot)
removebackground (bool) – DEPRECATED. Use remove_background
unit (str) – the unit for the MS data. Defaults to “A” for Ampere
U_name (str) – The name of the value to plot on the lower left y-axis. Defaults to the name of the series measurement.potential
J_name (str) – The name of the value to plot on the lower right y-axis. Defaults to the name of the series measurement.current
U_color (str) – The color to plot the variable given by ‘V_str’
J_color (str) – The color to plot the variable given by ‘J_str’
V_str (str) – DEPRECATED. Use U_name.
J_str (str) – DEPRECATED. Use J_name.
V_color (str) – DEPRECATED. Use U_color.
logplot (bool) – Whether to plot the MS data on a log scale (default True unless mass_lists are given)
legend (bool) – Whether to use a legend for the MS data (default True)
emphasis (str or None) – “top” for bigger top panel, “bottom” for bigger bottom panel, None for equal-sized panels
kwargs (dict) – Additional kwargs go to all calls of matplotlib’s plot()
- Returns
- (top_left, bottom_left, top_right, bottom_right) where:
axes[0] is top_left is MS data; axes[1] is bottom_left is potential; axes[2] is top_right is additional MS data if left and right mass_lists
or mol_lists were plotted (otherwise axes[2] is None); and
axes[3] is bottom_right is current.
- Return type
list of Axes
- plot_vs_potential(*, measurement=None, axes=None, mass_list=None, mass_lists=None, mol_list=None, mol_lists=None, tspan=None, tspan_bg=None, remove_background=None, removebackground=None, unit=None, logplot=False, legend=True, emphasis='top', **kwargs)[source]
Make an EC-MS plot vs time and return the axis handles.
Allocates tasks to ECPlotter.plot_measurement() and MSPlotter.plot_measurement()
- Parameters
measurement (ECMSMeasurement) – Defaults to the measurement to which the plotter is bound (self.measurement)
axes (list of three matplotlib axes) – axes[0] plots the MID data, axes[1] the current vs potential. By default three axes are made with axes[0] a top panel with 3/5 the area.
mass_list (list of str) – The names of the m/z values, eg. [“M2”, …] to plot. Defaults to all of them (measurement.mass_list)
mass_lists (list of list of str) – Alternately, two lists can be given for masses in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
mol_list (list of str) – The names of the molecules, eg. [“H2”, …] to plot. Defaults to all of them (measurement.mass_list)
mol_lists (list of list of str) – Alternately, two lists can be given for molecules in which case one list is plotted on the left y-axis and the other on the right y-axis of the top panel.
tspan (str or iter of float) – The time interval (t_start, t_end) to plot, wrt measurement.tstamp. Use tspan=”all” to plot all the data. Defaults to EC data tspan. See :fun:`determine_tspan`_ for more details.
tspan_bg (timespan) – A timespan for which to assume the signal is at its background. The average signals during this timespan are subtracted. If mass_lists are given rather than a single mass_list, tspan_bg must also be two timespans - one for each axis. Default is None for no background subtraction.
remove_background (bool) – Whether otherwise to subtract pre-determined background signals if available. Defaults to (not logplot)
removebackground – DEPRECATED. Use remove_background
unit (str) – the unit for the MS data. Defaults to “A” for Ampere
logplot (bool) – Whether to plot the MS data on a log scale (default False)
legend (bool) – Whether to use a legend for the MS data (default True)
emphasis (str or None) – “top” for bigger top panel, “bottom” for bigger bottom panel, None for equal-sized panels
kwargs (dict) – Additional kwargs go to all calls of matplotlib’s plot()
- ixdat.plotters.ecms_plotter.determine_tspan(tspan=None, measurement=None)[source]
Return a timespan based on a requested timespan and the EC-MS measurement
tspan is most directly given as two numbers, which are taken to be start time and end time (wrt to measurement.tstamp), e.g. [800, 1000]. tspan can also be one of these strings:
“all”: The full timespan from the first data point to the last “ec”: The full timespan of the EC data. “ms”: The full timespan of the MS data.
If tspan is not used, the measurement’s default timespan measurement.tspan is used, which for EC-MS measurements will be “ec”.
- Parameters
tspan (str or iter of float) – The timespan specification
measurement (ECMSMeasurement) – The measurement for which to determine a timespan
Spectra
The spectrum_plotter
module
Plotters for spectra and spectrumseries.
- class ixdat.plotters.spectrum_plotter.SpectroMeasurementPlotter(measurement=None)[source]
Plotter for measurements with spectrum_series
This makes use of the methods in SpectrumSeriesPlotter, but allows a second scanned variable (such as potential in the case of spectroelectrochemistry) to be used from the measurement instead of time data.
- heat_plot_vs(*, measurement=None, field=None, vs=None, vspan=None, xspan=None, ax=None, cmap_name='inferno', make_colorbar=False)[source]
Plot a SpectroMeasurement in two panels with time as x-asis.
The top panel is a heat plot with wavelength on y-axis and color representing spectrum. At most one of V_ref and t_ref should be given, and if neither are given the measurement’s default reference_spectrum is used to calculate the optical density.
- Parameters
measurement (SpectrumSeries) – The spectrum series to be plotted, if different from self.spectrum_series.
field (Field) – The field to be plotted, if different from spectrum_series.field
vs (str) – The name of the value series or time series to plot against.
vspan (iterable) – The span of the value series or time series to include
xspan (iterable) – The span of the spectral data to plot
ax (mpl.Axis) – The axes to plot on. A new one is made by default
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar. FIXME: colorbar at present mis-alignes axes
- plot_stacked_spectra_vs(*, measurement=None, vs=None, dt=None, t_list=None, dn=None, index_list=None, average=False, xspan=None, xspan_bg=None, scale_mode='auto', scale_factor=1, y_values='time', ax=None, color='k', **kwargs)[source]
Plot stacked spectra with a time-dependent value on the y-axis
This is commonly used for e.g. FTIR. Specify which spectra to plot by one of four ways: dt, t_list, dn, or n_list. See descriptions below.
- Parameters
measurement (SpectroMeasurement) – The spectromeasurement to plot data form, if different from self.measurement
vs (str) – The name of the value series to stack spectra according to.
dt (float) – time interval between spectra to plot, [s]. The first spectrum and those taken at times closest to each integer multiple of dt after are plotted.
t_list (list of float) – List of times for which to plot the spectrum, [s]. The closest spectrum to each time in the list is plotted.
dn (int) – number of spectra between plotted spectra
index_list (list of int) – List of indeces of spectra to plot
average (bool or int) – Whether and how to average spectra for plotting. False means no averaging. True means average all the spectra in the interval between spectra. An integer n means average the n/2 spectra before and n/2 spectra after the spectra at the given time or index
xspan (list of float) – Range of x-axis variable to include.
xspan_bg (list of float) – Range of x-axis variable for which to consider the signal at background. For each spectrum, the average y value in this range is subtracted.
scale_mode (str) –
The way to initially scale the spectra. Options: - “auto”: scale uniformly such that all spectra fit in
their given interval. The raw y-values are scaled by min(interval) / max(y range)
[no other scale_mode options yet]
scale_factor – A factor to apply on top of the initial scaling
y_values (str) – What to plot on the y-axis. Options: “time”, “n”
ax (Axis) – axis to plot on, if not a new axis
color (str) – color of traces. Defaults to black.
**kwargs – Additional key-word args are passed on to ax.plot()
- plot_waterfall_vs(*, measurement=None, field=None, vs=None, ax=None, cmap_name='jet', make_colorbar=True)[source]
Plot a SpectrumSeries as spectra colored by the value at which they are taken
- Parameters
measurement (SpectroMeasurement) – The measurement to be plotted if different from self.measurement.
field (Field) – The field to be plotted, if different from spectrum_series.field
vs (str) – The name of the value to use for the color scale. Defaults to time
ax (matplotlib Axis) – The axes to plot on. A new one is made by default.
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar.
- class ixdat.plotters.spectrum_plotter.SpectrumPlotter(spectrum=None)[source]
A plotter for a spectrum
- plot(*, spectrum=None, ax=None, **kwargs)[source]
Plot a spectrum as y (signal) vs x (scanning variable)
- Parameters
spectrum (Spectrum) – The spectrum to plot if different from self.spectrum
ax (mpl.Axis) – The axis to plot on. A new one is made by default.
kwargs – additional key-word arguments are given to ax.plot()
- class ixdat.plotters.spectrum_plotter.SpectrumSeriesPlotter(spectrum_series=None)[source]
A plotter for spectrum series, f.ex. spectra taken continuously over time
- heat_plot(*, spectrum_series=None, field=None, tspan=None, xspan=None, ax=None, cmap_name='inferno', make_colorbar=False, t=None, t_name=None, max_threshold=None, min_threshold=None, vmin=None, vmax=None, scanning_mask=None, continuous=None)[source]
Plot a spectrum series with t on the horizontal axis, x on the vertical axis, and color representing y.
- Parameters
spectrum_series (SpectrumSeries) – The spectrum series to be plotted, if different from self.spectrum_series.
field (Field) – The field to be plotted, if different from spectrum_series.field
tspan (iterable) – The span of the time data to plot
xspan (iterable) – The span of the spectral data to plot
ax (mpl.Axis) – The axes to plot on. A new one is made by default
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar. FIXME: colorbar at present mis-alignes axes
t (numpy array) – Time data to use if not the data in spectrum_series
t_name (str) – Name of time variable if not the one in spectrum_series
max_threshold (float) – Maximum value to display. Values above are set to max_threshold.
min_threshold (float) – Minimum value to display. Values below are set to min_threshold.
vmin (float) – minimum value to represent in colours. Defaults to minimum value (after applying min_threshold).
vmax (float) – maximum value to represent in colours. Defaults to maximum value (after applying max_threshold).
scanning_mask (list) – List of booleans to exclude from scanning variable before plotting data by setting y values to 0 (zero).
continuous (bool) – Optional. Whether to make a continuous heat plot (True) or a discrete heat plot for each spectrum (False). In the discrete case, each heat plot is a rectangle with the spectrum’s duration as its width, if available. If the duration is not available, each spectrum heat plot extends to the start of the next one. Defaults to the spectrum_series.continuous.
- property plot
The default plot of a SpectrumSeries is heat_plot
- plot_average(*, spectrum_series=None, ax=None, **kwargs)[source]
Take an average of the spectra and plot that.
- plot_stacked_spectra(spectrum_series=None, dt=None, t_list=None, dn=None, index_list=None, average=False, xspan=None, xspan_bg=None, scale_mode='auto', scale_factor=1, y_values='time', ax=None, color='k', **kwargs)[source]
Plot a selection of spectra, stacked
This is commonly used for e.g. FTIR. Specify which spectra to plot by one of four ways: dt, t_list, dn, or n_list. See descriptions below.
- Parameters
spectrum_series (SpectrumSeries) – What to plot from, if different from self.spectrum_series
dt (float) – time interval between spectra to plot, [s]. The first spectrum and those taken at times closest to each integer multiple of dt after are plotted.
t_list (list of float) – List of times for which to plot the spectrum, [s]. The closest spectrum to each time in the list is plotted.
dn (int) – number of spectra between plotted spectra
index_list (list of int) – List of indeces of spectra to plot
average (bool or int) – Whether and how to average spectra for plotting. False means no averaging. True means average all the spectra in the interval between spectra. An integer n means average the n/2 spectra before and n/2 spectra after the spectra at the given time or index
xspan (list of float) – Range of x-axis variable to include.
xspan_bg (list of float) – Range of x-axis variable for which to consider the signal at background. For each spectrum, the average y value in this range is subtracted.
scale_mode (str) –
The way to initially scale the spectra. Options: - “auto”: scale uniformly such that all spectra fit in
their given interval. The raw y-values are scaled by min(interval) / max(y range)
[no other scale_mode options yet]
scale_factor – A factor to apply on top of the initial scaling
y_values (str) – What to plot on the y-axis. Options: “time”, “n”
ax (Axis) – axis to plot on, if not a new axis
color (str) – color of traces. Defaults to black.
**kwargs – Additional key-word args are passed on to ax.plot()
- plot_waterfall(*, spectrum_series=None, field=None, ax=None, cmap_name='jet', make_colorbar=True, t=None, t_name=None)[source]
Plot a SpectrumSeries as spectra colored by the time at which they are taken
This is commonly used for e.g. in-situ UV-Vis spectrometry
- Parameters
spectrum_series (SpectrumSeries) – The spectrum series to be plotted, if different from self.spectrum_series.
field (Field) – The field to be plotted, if different from spectrum_series.field
ax (matplotlib Axis) – The axes to plot on. A new one is made by default.
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar.
t (numpy array) – Time data to use if not the data in spectrum_series
t_name (str) – Name of time variable if not the one in spectrum_series
Spectroelectrochemistry
The sec_plotter
module
Plotters for spectroelectrochemistry. Makes use of those in spectrum_plotter.py
- class ixdat.plotters.sec_plotter.ECOpticalPlotter(measurement=None)[source]
- plot_measurement(*, measurement=None, tspan=None, wlspan=None, axes=None, V_ref=None, t_ref=None, cmap_name='inferno', make_colorbar=False, **kwargs)[source]
Plot an SECMeasurement in two panels with time as x-asis.
The top panel is a heat plot with wavelength on y-axis and color representing spectrum. At most one of V_ref and t_ref should be given, and if neither are given the measurement’s default reference_spectrum is used to calculate the optical density.
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
tspan (timespan) – The timespan of data to keep for the measurement.
wlspan (iterable) – The wavelength span of spectral data to plot
axes (list of mpl.Axis) – The axes to plot on. axes[0] is for the heat plot, axes[1] for potential, and axes[2] for current. The axes are optional and a new set of axes, where axes[1] and axes[2] are twinned on x, are generated if not provided.
V_ref (float) – Potential to use as reference for calculating optical density
t_ref (float) – Time to use as a reference for calculating optical density
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar. FIXME: colorbar at present misaligns axes
kwargs – Additional key-word arguments are passed on to ECPlotter.plot_measurement().
- Returns
- axes=[spectra, potential, None, current]
axes[0] is the top axis with the heat map of the spectra axes[1] is the bottom left axis with electrochemical potential axes[2] is None (this is where a top right axis would go) axes[3] is the bottom right axis with electrode current
- Return type
list of Axes
- plot_vs_potential(*, measurement=None, tspan=None, vspan=None, U_name=None, J_name=None, wlspan=None, axes=None, V_ref=None, t_ref=None, cmap_name='inferno', make_colorbar=False, **kwargs)[source]
Plot an SECMeasurement in two panels with time as x-asis.
The top panel is a heat plot with wavelength on y-axis and color representing spectrum. At most one of V_ref and t_ref should be given, and if neither are given the measurement’s default reference_spectrum is used to calculate the optical density.
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
tspan (timespan) – The timespan of data to keep for the measurement.
vspan (timespan) – The potential span of data to keep for the measurement.
U_name (str) – Optional. The name of the data series to use as potential.
J_name (str) – Optional. The name of the data series to use as current.
wlspan (iterable) – The wavelength span of spectral data to plot
axes (list of mpl.Axis) – The axes to plot on. axes[0] is for the heat plot, axes[1] for potential, and axes[2] for current. The axes are optional and a new set of axes, where axes[1] and axes[2] are twinned on x, are generated if not provided.
V_ref (float) – Potential to use as reference for calculating optical density
t_ref (float) – Time to use as a reference for calculating optical density
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar. FIXME: colorbar at present mis-alignes axes
kwargs – Additional key-word arguments are passed on to ECPlotter.plot_measurement().
- Returns
- axes=[spectra, potential, None, current]
axes[0] is the top axis with the heat map of the spectra axes[1] is the bottom left axis with electrochemical potential axes[2] is None (this is where a top right axis would go) axes[3] is the bottom right axis with electrode current
- Return type
list of Axes
- plot_waterfall(*, measurement=None, ax=None, V_ref=None, t_ref=None, cmap_name='jet', make_colorbar=True)[source]
Plot an SECMeasurement as spectra colored based on potential.
The top panel is a heat plot with wavelength on y-axis and color representing spectrum. At most one of V_ref and t_ref should be given, and if neither are given the measurement’s default reference_spectrum is used to calculate the optical density.
This uses
plot_waterfall()
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
ax (matplotlib Axis) – The axes to plot on. A new one is made by default.
V_ref (float) – potential to use as reference for calculating optical density
t_ref (float) – time to use as a reference for calculating optical density
cmap_name (str) – The name of the colormap to use. Defaults to “jet”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html
make_colorbar (bool) – Whether to make a colorbar.
- plot_wavelengths(*, measurement=None, wavelengths=None, axes=None, cmap_name='jet', tspan=None, **kwargs)[source]
Plot the dO.D. for specific wavelength in the top panel and EC in bottom
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
wavelengths (list of str) – The names of the wavelengths to track as strings, e.g. “w400” for 400 nm
axes (list of Ax) – The axes to plot on, defaults to new matplotlib axes
cmap_name (str) – The name of the colormap to use. Defaults to “jet”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html
tspan (timespan) – The timespan to plot
**kwargs – Additional key-word arguments are passed on to ECPlotter.plot_measurement
- plot_wavelengths_vs_potential(*, measurement=None, wavelengths=None, axes=None, cmap_name='jet', tspan=None, **kwargs)[source]
Plot the dO.D. for specific wavelength in the top panel vs potential
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
wavelengths (list of str) – The names of the wavelengths to track as strings, e.g. “w400” for 400 nm
axes (list of Ax) – The axes to plot on, defaults to new matplotlib axes
cmap_name (str) – The name of the colormap to use. Defaults to “jet”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html
tspan (timespan) – The timespan to plot
**kwargs – Additional key-word arguments are passed on to ECPlotter.plot_vs_potential
- class ixdat.plotters.sec_plotter.SECPlotter(measurement=None)[source]
A spectroelectrochemistry (SEC) matplotlib plotter.
- plot_measurement(*, measurement=None, field=None, tspan=None, xspan=None, axes=None, cmap_name='inferno', make_colorbar=False, continuous=None, **kwargs)[source]
Plot an SECMeasurement in two panels with time as x-asis.
The top panel is a heat plot with the spectral scanning variable (x) on y-axis and color representing the value of the spectral data. The bottom panel contains electrochemistry data.
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
field (Field) – The field with the spectral data to plot. Defaults to measurement.spectra
tspan (timespan) – The timespan of data to keep for the measurement.
xspan (iterable) – The span of spectral data to plot
axes (list of mpl.Axis) – The axes to plot on. axes[0] is for the heat plot, axes[1] for potential, and axes[2] for current. The axes are optional and a new set of axes, where axes[1] and axes[2] are twinned on x, are generated if not provided.
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar. FIXME: colorbar at present mis-alignes axes
kwargs – Additional key-word arguments are passed on to ECPlotter.plot_measurement().
continuous (bool) – Optional. Whether to make a continuous heat plot (True) or a discrete heat plot for each spectrum (False). In the discrete case, each heat plot is a rectangle with the spectrum’s duration as its width, if available. If the duration is not available, each spectrum heat plot extends to the start of the next one. Defaults to measurement.spectrum_series.continuous.
- Returns
- axes=[spectra, potential, None, current]
axes[0] is the top axis with the heat map of the spectra axes[1] is the bottom left axis with electrochemical potential axes[2] is None (this is where a top right axis would go) axes[3] is the bottom right axis with electrode current
- Return type
list of Axes
- plot_vs_potential(*, measurement=None, field=None, tspan=None, vspan=None, U_name=None, J_name=None, xspan=None, axes=None, cmap_name='inferno', make_colorbar=False, **kwargs)[source]
Plot an SECMeasurement in two panels with potential as x-asis.
The top panel is a heat plot with wavelength on y-axis and color representing spectrum. At most one of V_ref and t_ref should be given, and if neither are given the measurement’s default reference_spectrum is used to calculate the optical density.
- Parameters
measurement (Measurement) – The measurement to be plotted, if different from self.measurement
field (Field) – The field with the spectral data to plot. Defaults to measurement.spectra
tspan (timespan) – The timespan of data to keep for the measurement.
vspan (timespan) – The potential span of data to keep for the measurement.
U_name (str) – Optional. The name of the data series to use as potential.
J_name (str) – Optional. The name of the data series to use as current.
xspan (iterable) – The span of spectral data to plot
axes (list of numpy Axes) – The axes to plot on. axes[0] is for the heat plot and axes[1] for potential. New are made by default.
cmap_name (str) – The name of the colormap to use. Defaults to “inferno”, see https://matplotlib.org/3.5.0/tutorials/colors/colormaps.html#sequential
make_colorbar (bool) – Whether to make a colorbar.
kwargs – Additional key-word arguments are passed on to ECPlotter.plot_vs_potential().