matchms.plotting.spectrum_plots module

matchms.plotting.spectrum_plots.plot_spectra_array(spectrums, n_cols: int = 2, peak_color='darkblue', dpi: int = 200, title: str | None = None, **spectrum_kws) Axes[source]

Mirror plot two MS/MS spectra.

Code is largely taken from package “spectrum_utils”.

Parameters:
  • spectrums (list of matchms.Spectrum) – List of spectra to be plotted in a single figure.

  • n_cols – Number of spectra to be plotted per row. Default is 4.

  • spectrum_kws – Keyword arguments for plot_spectrum().

matchms.plotting.spectrum_plots.plot_spectra_mirror(spec_top, spec_bottom, ax: Axes | None = None, **spectrum_kws) Axes[source]

Mirror plot two MS/MS spectra.

Code is largely taken from package “spectrum_utils”.

Parameters:
  • spec_top (matchms.Spectrum) – The spectrum to be plotted on the top.

  • spec_bottom (matchms.Spectrum) – The spectrum to be plotted on the bottom.

  • ax – Axes instance on which to plot the spectrum. If None the current Axes instance is used.

  • spectrum_kws – Keyword arguments for plot_spectrum().

Returns:

The matplotlib Axes instance on which the spectra are plotted.

Return type:

plt.Axes

matchms.plotting.spectrum_plots.plot_spectrum(spectrum, annotate_ions: bool = False, mirror_intensity: bool = False, grid: bool | str = True, ax: Axes | None = None, peak_color='teal', min_mz: float | None = None, max_mz: float | None = None, **plt_kwargs) Axes[source]

Plot a single MS/MS spectrum.

Code is largely taken from package “spectrum_utils”.

Parameters:
  • spectrum (matchms.Spectrum) – The spectrum to be plotted.

  • annotate_ions – Flag indicating whether or not to annotate fragment using peak comments (if present in the spectrum). The default is True.

  • mirror_intensity – Flag indicating whether to flip the intensity axis or not.

  • grid – Draw grid lines or not. Either a boolean to enable/disable both major and minor grid lines or ‘major’/’minor’ to enable major or minor grid lines respectively.

  • ax – Axes instance on which to plot the spectrum. If None the current Axes instance is used.

  • peak_color – Set color of peaks in plot.

  • min_mz – Set lower limit of the plots x-axis to min_mz. Default is None.

  • max_mz – Set upper limit of the plots x-axis to min_mz. Default is None.

Returns:

The matplotlib Axes instance on which the spectrum is plotted.

Return type:

plt.Axes