pyopenms.plotting.plot_spectrum#

pyopenms.plotting.plot_spectrum(spectrum: MSSpectrum, color_ions: bool = True, annotate_ions: bool = True, matched_peaks: Set | None = None, annot_kws: Dict | None = None, mirror_intensity: bool = False, grid: bool | str = False, colormap: Dict | None = None, spine: bool = False, show_unmatched_peaks=True, ax=None)#

Plot an MS/MS spectrum.

Parameters:
  • spectrum (MSSpectrum) – The spectrum to be plotted. Reads annotations from the first StringDataArray if it has the same length as the number of peaks.

  • color_ions (bool, optional) – Flag indicating whether to color annotated fragment ions. The default is True.

  • annotate_ions (bool, optional) – Flag indicating whether to annotate fragment ions. The default is True.

  • matched_peaks (Optional[Set], optional) – Indices of matched peaks in a spectrum alignment.

  • annot_kws (Optional[Dict], optional) – Keyword arguments for ax.text to customize peak annotations.

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

:type mirror_intensity : bool, optional

Parameters:
  • grid (Union[bool, str], optional) – 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.

  • colormap – A dictionary mapping ion types to colors. Accepted keys are the ion types: ‘a’, ‘b’, ‘c’, ‘x’, ‘y’,

‘z’, ‘p’, ‘f’. None for unannotated peaks. ‘matched’ and ‘unmatched’ for peaks in matched_peaks and not in matched_peaks, respectively, if provided. :type colormap: Optional[Dict], optional

Parameters:
  • spine (bool, optional) – Flag indicating whether to show the right and top spines.

  • show_unmatched_peaks (bool, optional) – Flag indicating whether to show unmatched peaks.

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

:type ax : Optional[plt.Axes], optional

:return The matplotlib Axes instance on which the spectrum is plotted. :rtype: plt.Axes