Plotting

spinlab.plotting.general.fancy_plot(data, xlim=[], title='', showPar=False, showgValues=False, *args, **kwargs)

Streamline Plot function for sldata objects

This function creates streamlined plots for NMR and EPR spectra. The type of the spectrum is detected from the attribute "experiment_type" of the sldata object. Currently the following types are implemented: nmr_spectrum, epr_spectrum, enhancements_P, and inversion_recovery. The function will automatically format the plot according to the "experiment_type" attribute.

Parameters:
  • data (SpinData) -- SpinData object with values to plot

  • xlim (tuple) -- List of limit values for plotting function

  • title (str) -- Plot title

  • showPar (boolean) -- Toggle whether to show experiment parameters

Returns:

Matplotlib plot object(s) returned by the underlying plot call.

Return type:

list

Examples

Simply just plotting the sldata object:

>>> sl.fancy_plot(data)

Plot EPR spectrum from 344 mT to 354 mT, show experimental parameters:

>>> sl.fancy_plot(data, xlim=[344, 354], title="EPR Spectrum", showPar=True)
spinlab.plotting.general.plot(data, *args, **kwargs)

Plot function for sldata object

Parameters:
  • data (SpinData) -- SpinData object for matplotlib plot function

  • *args -- Additional positional arguments passed to the Matplotlib plot function.

  • **kwargs -- Additional keyword arguments passed to the Matplotlib plot function. If any of semilogy, semilogx, polar, loglog, scatter, errorbar, or step is present and evaluates to True, the corresponding Matplotlib function is used instead of the standard plot.

Note: :returns: Matplotlib plot object(s) returned by the underlying plot call. :rtype: list

Examples

Plotting a SpinData object:

>>> sl.plt.figure()
>>> sl.plot(data)
>>> sl.plt.show()

# Plotting two SpinData objects (data1 and data2) on the same figure:

>>> sl.plt.figure()
>>> sl.plot(data1)
>>> sl.plot(data2)
>>> sl.plt.show()

Plotting a SpinData object with some custom parameters:

>>> sl.plt.figure()
>>> sl.plot(data, 'k-', linewidth = 3.0, alpha = 0.5)
>>> sl.plt.show()

Plotting a SpinData object with a semilogy plot (possible arguments: semilogy=1, semilogy=True, semilogy="True") Forwarded arguments: semilogy, semilogx, polar, loglog, scatter, errorbar or step The absolute value is taken to ensure that the y axis is always positive

>>> sl.plt.figure()
>>> sl.plot(np.abs(data), 'k-', linewidth = 3.0, alpha = 0.5, semilogy=1)
>>> sl.plt.show()
spinlab.plotting.image.imshow(data, *args, **kwargs)

Image Plot for sldata object

Parameters:
  • data (SpinData) -- SpinData object for image plot

  • *args -- Additional positional arguments passed to the Matplotlib imshow function.

  • **kwargs -- Additional keyword arguments passed to the Matplotlib imshow function.

Returns:

Matplotlib image object returned by imshow.

Return type:

AxesImage

Examples

Plotting a sldata object

>>> sl.plt.figure()
>>> sl.imshow(data)
>>> sl.plt.show()

Plotting a workspace (sldata_collection)

>>> sl.plt.figure()
>>> sl.imshow(data)
>>> sl.plt.show()
spinlab.plotting.stack_plot.stack(data, *args, offset=None, **kwargs)

Stack Plot for 2D data

Parameters:
  • data (SpinData) -- SpinData object to plot.

  • *args -- Additional positional arguments passed to the Matplotlib plot function.

  • offset (float, optional) -- Value to offset each spectrum. Defaults to the maximum absolute value in the data.

  • **kwargs -- Additional keyword arguments passed to the Matplotlib plot function.

Examples

>>> sl.plt.figure()
>>> sl.stack(data)
>>> sl.plt.show()
spinlab.plotting.stack_plot.waterfall(data, dx, dy, *args, **kwargs)

Waterfall plot for 2d data

Parameters:
  • data (slData) -- 2d Data object for waterfall plot

  • dx (float, int) -- x-increment for each line

  • dy (float, int) -- y-increment for each line

Examples

>>> sl.plt.figure()
>>> sl.waterfall(data)
>>> sl.plt.show()

Standard spinlab colors