Pyteomics documentation v3.4.1

pylab_aux - auxiliary functions for plotting with pylab

Contents   ::   xml - utilities for XML parsing  »

pylab_aux - auxiliary functions for plotting with pylab

This module serves as a collection of useful routines for data plotting with matplotlib.

Generic plotting

plot_line() - plot a line.

scatter_trend() - plot a scatter plot with a regression line.

plot_function_3d() - plot a 3D graph of a function of two variables.

plot_function_contour() - plot a contour graph of a function of two variables.

FDR control

plot_qvalue_curve() - plot the dependence of q-value on the amount of PSMs (similar to a ROC curve).

Dependencies

This module requires matplotlib.


pyteomics.pylab_aux.plot_function_3d(x, y, function, **kwargs)[source]

Plot values of a function of two variables in 3D.

More on 3D plotting in pylab:

http://www.scipy.org/Cookbook/Matplotlib/mplot3D

Parameters:

x, y : array_like of float

The plotting range.

function : function

The function to plot.

plot_type : {‘surface’, ‘wireframe’, ‘scatter’, ‘contour’, ‘contourf’}

The type of a plot, see scipy cookbook for examples. The default value is ‘surface’.

num_contours : int

The number of contours to plot, 50 by default.

xlabel, ylabel, zlabel : str, optional

The axes labels. Empty by default.

title : str, optional

The title. Empty by default.

**kwargs : passed to the respective plotting function.

pyteomics.pylab_aux.plot_function_contour(x, y, function, **kwargs)[source]

Make a contour plot of a function of two variables.

Parameters:

x, y : array_like of float

The positions of the nodes of a plotting grid.

function : function

The function to plot.

filling : bool

Fill contours if True (default).

num_contours : int

The number of contours to plot, 50 by default.

xlabel, ylabel : str, optional

The axes labels. Empty by default.

title : str, optional

The title. Empty by default.

**kwargs : passed to pylab.contour() or pylab.contourf().

pyteomics.pylab_aux.plot_line(a, b, xlim=None, *args, **kwargs)[source]

Plot a line y = a * x + b.

Parameters:

a, b : float

The slope and intercept of the line.

xlim : tuple, optional

Minimal and maximal values of x. If not given, pylab.xlim() will be called.

*args, **kwargs : passed to pylab.plot() after x and y values.

Returns:

out : matplotlib.lines.Line2D

The line object.

pyteomics.pylab_aux.plot_qvalue_curve(qvalues, *args, **kwargs)[source]

Plot a curve with q-values on the X axis and corresponding PSM number (starting with 1) on the Y axis.

Parameters:

qvalues : array-like

An array of q-values for sorted PSMs.

xlabel : str, optional

Label for the X axis. Default is “q-value”.

ylabel : str, optional

Label for the Y axis. Default is “# of PSMs”.

title : str, optional

The title. Empty by default.

*args, **kwargs : will be given to pylab.plot() after x and y.

Returns:

out : matplotlib.lines.Line2D

pyteomics.pylab_aux.scatter_trend(x, y=None, **kwargs)[source]

Make a scatter plot with a linear regression.

Parameters:

x, y : array_like of float

1-D arrays of floats. If y is omitted, x must be a 2-D array of shape (N, 2).

plot_trend : bool, optional

If True then plot a trendline (default).

plot_sigmas : bool, optional

If True then plot confidence intervals of the linear fit. False by default.

show_legend : bool, optional

If True, a legend will be shown with linear fit equation, correlation coefficient, and standard deviation from the fit. Default is True.

title : str, optional

The title. Empty by default.

xlabel, ylabel : str, optional

The axes labels. Empty by default.

alpha_legend : float, optional

Legend box transparency. 1.0 by default

scatter_kwargs : dict, optional

Keyword arguments for pylab.scatter(). Empty by default.

plot_kwargs : dict, optional

Keyword arguments for plot_line(). By default, sets xlim and label.

legend_kwargs : dict, optional

Keyword arguments for pylab.legend(). Default is {'loc': 'upper left'}.

sigma_kwargs : dict, optional

Keyword arguments for pylab.plot() used for sigma lines. Default is {'color': 'red', 'linestyle': 'dashed'}.

sigma_values : iterable, optional

Each value will be multiplied with standard error of the fit, and the line shifted by the resulting value will be plotted. Default is range(-3, 4).

regression : callable, optional

Function to perform linear regression. Will be given x and y as arguments. Must return a 4-tuple: (a, b, r, stderr). Default is pyteomics.auxiliary.linear_regression().

Returns:

out : tuple

A (scatter_plot, trend_line, sigma_lines, legend) tuple.

Contents   ::   xml - utilities for XML parsing  »