### Navigation

- index
- modules |
- next |
- previous |
- pymzML 0.7.4 documentation »

# 6. Plotting functions

Plotting functions for pymzML

class `plot.``Factory`(filename=None)

  Class to plot pymzml.spec.Spectrum as svg/xhtml.

  Parameters: | filename (string) – Name for the output file. Default = “spectra.xhtml”

  Example:

      >>> import pymzml, get_example_file
      >>> mzMLFile = 'profile-mass-spectrum.mzml'
      >>> example_file = get_example_file.open_example(mzMLFile)
      >>> run = pymzml.run.Run("../mzML_example_files/"+mzMLFile, precisionMSn = 250e-6)
      >>> p = pymzml.plot.Factory()
      >>> for spec in run:
      >>>     p.newPlot()
      >>>     p.add(spec.peaks, color=(200,00,00), style='circles')
      >>>     p.add(spec.centroidedPeaks, color=(00,00,00), style='sticks')
      >>>     p.add(spec.reprofiledPeaks, color=(00,255,00), style='circles')
      >>>     p.save( filename="output/plotAspect.xhtml" , mzRange = [745.2,745.6] )

  `add`(data, color=(0, 0, 0), style='sticks', mzRange=[None, None])

    Add data to the graph.

    Parameters:

    - data (list of tuples (mz,i)) – The data added to the graph
    - color (tuple (R,G,B)) – color encoded in RGB. Default = (0,0,0)
    - style (string) – plotting style. Default = “circles”.
    - mzRange (tuple of minMZ,maxMZ) – Boundaries that should be added to the current plot

    Currently supported styles are:
      - ‘emptycircles’
      - ‘circles’
      - ‘sticks’
      - ‘squares’
      - ‘area’
      - ‘triangle’
      - ‘label’

    NOTE: The data format for label style is [( mz1, ‘label1’ ), ( mz2, ‘label2’ ), ( mz3, ‘label3’ ) ].

  `info`()

    Returns summary about the plotting factory, i.e.how many plots and how many datasets per plot.

  `newPlot`(header=None, mzRange=[None, None], normalize=False)

    Add new plot to the plotFactory.

    Parameters:

    - header (string) – an optional title that will be printed above the plot
    - mzRange (tuple of minMZ,maxMZ) – Boundaries of the new plot
    - normalize – whether or not the individal data sets are normalized in the plot

  `save`(filename=None, mzRange=[None, None])

    Saves all plots and their data points that have been added to the plotFactory.

    Parameters:

    - filename (string) – Name for the output file. Default = “spectra.xhtml”
    - mzRange (list) – m/z range which should be considered [start, end]. Default = [ `None` , `None` ]

### Navigation

- index
- modules |
- next |
- previous |
- pymzML 0.7.4 documentation »