parameters: (spectrum: MSSpectrum, color_ions: bool = True,
               annotate_ions: bool = True, matched_peaks: Optional[Set] = None, annot_kws: Optional[Dict] = None,
               mirror_intensity: bool = False, grid: Union[bool, str] = True, ax=None)
return_statement: return ax
docstring: Plot an MS/MS spectrum.
  
      Parameters
      ----------
      spectrum : MSSpectrum
          The spectrum to be plotted.
      color_ions : bool, optional
          Flag indicating whether or not to color annotated fragment ions. The
          default is True.
      annotate_ions : bool, optional
          Flag indicating whether or not 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 : bool, optional
          Flag indicating whether to flip the intensity axis or not.
      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.
      ax : Optional[plt.Axes], optional
          Axes instance on which to plot the spectrum. If None the current Axes
          instance is used.
  
      Returns
      -------
      plt.Axes
          The matplotlib Axes instance on which the spectrum is plotted.
docstring_summary: Plot an MS/MS spectrum.
docstring_tokens: Plot an MS / MS spectrum .
function: def plot_spectrum(spectrum: MSSpectrum, color_ions: bool = True,
               annotate_ions: bool = True, matched_peaks: Optional[Set] = None, annot_kws: Optional[Dict] = None,
               mirror_intensity: bool = False, grid: Union[bool, str] = True, ax=None):
      """
      Plot an MS/MS spectrum.
  
      Parameters
      ----------
      spectrum : MSSpectrum
          The spectrum to be plotted.
      color_ions : bool, optional
          Flag indicating whether or not to color annotated fragment ions. The
          default is True.
      annotate_ions : bool, optional
          Flag indicating whether or not 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 : bool, optional
          Flag indicating whether to flip the intensity axis or not.
      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.
      ax : Optional[plt.Axes], optional
          Axes instance on which to plot the spectrum. If None the current Axes
          instance is used.
  
      Returns
      -------
      plt.Axes
          The matplotlib Axes instance on which the spectrum is plotted.
      """
      import matplotlib.pyplot as plt
      import matplotlib.ticker as mticker
  
      if ax is None:
          ax = plt.gca()
  
      mz, intensity = spectrum.get_peaks()
      min_mz = max(0, math.floor(mz[0] / 100 - 1) * 100)
      max_mz = math.ceil(mz[-1] / 100 + 1) * 100
      ax.set_xlim(min_mz, max_mz)
      ax.yaxis.set_major_formatter(mticker.PercentFormatter(xmax=1.))
      y_max = 1.15 if annotate_ions else 1.05
      ax.set_ylim(*(0, y_max) if not mirror_intensity else (-y_max, 0))
  
      max_intensity = intensity.max()
      if len(spectrum.getStringDataArrays()) > 0 and len(list(spectrum.getStringDataArrays()[0])) == len(mz):
          annotations = [ion.decode() for ion in spectrum.getStringDataArrays()[0]]
      else:
          annotations = itertools.repeat(None)
      annotation_kws = {
          'horizontalalignment': 'left' if not mirror_intensity else 'right',
          'verticalalignment': 'center', 'rotation': 90,
          'rotation_mode': 'anchor', 'zorder': 5}
      if annot_kws is not None:
          annotation_kws.update(annot_kws)
      for i_peak, (peak_mz, peak_intensity, peak_annotation) in enumerate(zip(mz, intensity, annotations)):
          peak_intensity = peak_intensity / max_intensity
          if mirror_intensity:
              peak_intensity *= -1
  
          matched = matched_peaks is not None and i_peak in matched_peaks
  
          color, zorder = _annotate_ion(
              peak_mz, peak_intensity, peak_annotation, color_ions, annotate_ions,
              matched, annotation_kws, ax)
  
          ax.plot([peak_mz, peak_mz], [0, peak_intensity], color=color, zorder=zorder)
  
      ax.xaxis.set_minor_locator(mticker.AutoLocator())
      ax.yaxis.set_minor_locator(mticker.AutoLocator())
      ax.xaxis.set_minor_locator(mticker.AutoMinorLocator())
      ax.yaxis.set_minor_locator(mticker.AutoMinorLocator())
      if grid in (True, 'both', 'major'):
          ax.grid(b=True, which='major', color='#9E9E9E', linewidth=0.2)
      if grid in (True, 'both', 'minor'):
          ax.grid(b=True, which='minor', color='#9E9E9E', linewidth=0.2)
      ax.set_axisbelow(True)
  
      ax.tick_params(axis='both', which='both', labelsize='small')
      y_ticks = ax.get_yticks()
      ax.set_yticks(y_ticks[y_ticks <= 1.])
  
      ax.set_xlabel('m/z', style='italic')
      ax.set_ylabel('Intensity')
  
      return ax
function_tokens: def plot_spectrum ( spectrum : MSSpectrum , color_ions : bool = True , annotate_ions : bool = True , matched_peaks : Optional [ Set ] = None , annot_kws : Optional [ Dict ] = None , mirror_intensity : bool = False , grid : Union [ bool , str ] = True , ax = None ) : import matplotlib . pyplot as plt import matplotlib . ticker as mticker if ax is None : ax = plt . gca ( ) mz , intensity = spectrum . get_peaks ( ) min_mz = max ( 0 , math . floor ( mz [ 0 ] / 100 - 1 ) * 100 ) max_mz = math . ceil ( mz [ - 1 ] / 100 + 1 ) * 100 ax . set_xlim ( min_mz , max_mz ) ax . yaxis . set_major_formatter ( mticker . PercentFormatter ( xmax = 1. ) ) y_max = 1.15 if annotate_ions else 1.05 ax . set_ylim ( * ( 0 , y_max ) if not mirror_intensity else ( - y_max , 0 ) ) max_intensity = intensity . max ( ) if len ( spectrum . getStringDataArrays ( ) ) > 0 and len ( list ( spectrum . getStringDataArrays ( ) [ 0 ] ) ) == len ( mz ) : annotations = [ ion . decode ( ) for ion in spectrum . getStringDataArrays ( ) [ 0 ] ] else : annotations = itertools . repeat ( None ) annotation_kws = { 'horizontalalignment' : 'left' if not mirror_intensity else 'right' , 'verticalalignment' : 'center' , 'rotation' : 90 , 'rotation_mode' : 'anchor' , 'zorder' : 5 } if annot_kws is not None : annotation_kws . update ( annot_kws ) for i_peak , ( peak_mz , peak_intensity , peak_annotation ) in enumerate ( zip ( mz , intensity , annotations ) ) : peak_intensity = peak_intensity / max_intensity if mirror_intensity : peak_intensity *= - 1 matched = matched_peaks is not None and i_peak in matched_peaks color , zorder = _annotate_ion ( peak_mz , peak_intensity , peak_annotation , color_ions , annotate_ions , matched , annotation_kws , ax ) ax . plot ( [ peak_mz , peak_mz ] , [ 0 , peak_intensity ] , color = color , zorder = zorder ) ax . xaxis . set_minor_locator ( mticker . AutoLocator ( ) ) ax . yaxis . set_minor_locator ( mticker . AutoLocator ( ) ) ax . xaxis . set_minor_locator ( mticker . AutoMinorLocator ( ) ) ax . yaxis . set_minor_locator ( mticker . AutoMinorLocator ( ) ) if grid in ( True , 'both' , 'major' ) : ax . grid ( b = True , which = 'major' , color = '#9E9E9E' , linewidth = 0.2 ) if grid in ( True , 'both' , 'minor' ) : ax . grid ( b = True , which = 'minor' , color = '#9E9E9E' , linewidth = 0.2 ) ax . set_axisbelow ( True ) ax . tick_params ( axis = 'both' , which = 'both' , labelsize = 'small' ) y_ticks = ax . get_yticks ( ) ax . set_yticks ( y_ticks [ y_ticks <= 1. ] ) ax . set_xlabel ( 'm/z' , style = 'italic' ) ax . set_ylabel ( 'Intensity' ) return ax