Using plot_multiple to plot several datasets on the same figure

In this example, we will display several Raman datasets on the same figure using the plot_multiple helper. Unlike multiplot, which creates a grid of panels, plot_multiple overlays several datasets on one shared axes. Several options are available to customize that overlay.

Import spectrochempy as usual

import spectrochempy as scp

Load and inspect the data

B1 = scp.read("ramandata/labspec/serie190214-1.txt")

Basic plot with categorical colors (cmap=None):

_ = B1.plot(cmap=None, lw=1)
plot plot multiple

Preprocess: restrict and detrend

Restrict the region of interest (use floats for coordinate slicing):

B2 = B1[:, 60.0:]

Remove the drift with detrend:

B3 = scp.detrend(B2)
_ = B3.plot(cmap=None)
plot plot multiple

Select a subset of spectra for the overlay:

B4 = B3[:5]
_ = B4.plot(cmap=None)
plot plot multiple

Overlay spectra with plot_multiple

Unlike multiplot (which creates a grid of panels), plot_multiple overlays several 1D datasets on a shared axes. Here we use line rendering with a vertical shift for visual separation:

datasets = list(B4)
_ = scp.plot_multiple(
    datasets,
    method="pen",
    legend="best",
    labels=["A", "B", "C", "D", "E"],
    color=["black", "red", "green", "blue", "violet"],
    lw=[1, 2.5, 1, 1, 1],
    ls="-",
    shift=1000,
)
plot plot multiple

Uncomment the following line to display all figures when running the script directly with Python.

# scp.show()

Total running time of the script: (0 minutes 1.037 seconds)