libgunshotmatch_mpl.chromatogram

Common chromatogram drawing functionality.

Classes:

OneDPScalarFormatter([useOffset, …])

Customised ScalarFormatter to always show one decimal place.

Functions:

add_repeat_name(axes, repeat_name)

Add a repeat name label to the top left of the given axes.

annotate_peaks(project, figure, ax, *[, …])

Annotate largest peaks with compound names.

draw_chromatograms(project, figure, axes)

Draw chromatogram for each repeat in the project.

draw_combined_chromatogram(project, figure, …)

Draw a combined “chromatogram” for the project.

draw_peak_arrows(figure, axes, rt, intensity)

Draw an arrow above the peak at the given retention time.

draw_peak_vlines(axes, rt, intensity[, colour])

Draw a vertical line to the apex of the peak at the given retention time.

ylabel_sci_1dp(axes)

Set matplotlib axes to use scientific notation (with math text and one decimal place).

ylabel_use_sci(axes)

Set matplotlib axes to use scientific notation (with math text).

class OneDPScalarFormatter(useOffset=None, useMathText=None, useLocale=None)[source]

Bases: ScalarFormatter

Customised ScalarFormatter to always show one decimal place.

New in version 0.2.0.

add_repeat_name(axes, repeat_name)[source]

Add a repeat name label to the top left of the given axes.

Parameters
annotate_peaks(project, figure, ax, *, top_n_peaks=None, minimum_area=0)[source]

Annotate largest peaks with compound names.

Parameters
  • project (Project)

  • figure (Figure)

  • ax (Axes)

  • top_n_peaks (Optional[int]) – Show only the n largest peaks. Default None.

  • minimum_area (float) – Show only peaks larger than the given area. Default 0.

New in version 0.4.0.

draw_chromatograms(project, figure, axes)[source]

Draw chromatogram for each repeat in the project.

Parameters
draw_combined_chromatogram(project, figure, ax, *, top_n_peaks=None, minimum_area=0, use_median=False, use_peak_height=False, show_points=False, colourmap=None)[source]

Draw a combined “chromatogram” for the project.

A bar chart for peak area/height styled as a chromatogram, with time on the x-axis.

Parameters
  • project (Project)

  • figure (Figure)

  • ax (Axes)

  • top_n_peaks (Optional[int]) – Show only the n largest peaks. Default None.

  • minimum_area (float) – Show only peaks larger than the given area (or peak height, as applicable). Default 0.

  • use_median (bool) – Show the median and inter-quartile range, rather than the mean and standard deviation. Default False.

  • use_peak_height (bool) – Show the peak height and not the peak area. Default False.

  • show_points (bool) – Show individual retention time / peak area scatter points. Default False.

  • colourmap (Union[Colormap, Callable[[float], Tuple[int, int, int, int]], None]) – Optional colourmap function for the bars. By default sequential bars are given colours from the default colour cycle. If colourmap is provided this function calculates the bar colour from the retention time. The function must return a tuple of RGBA values when given a float between 0 and 1. Default None.

New in version 0.2.0.

Changed in version 0.4.0: Added the use_median, use_peak_height and show_points keyword arguments.

Changed in version 0.5.0:
  • Moved to the combined_chromatogram module.

  • Y-axis label now reflects use_median and use_peak_height options.

draw_peak_arrows(figure, axes, rt, intensity, colour=None)[source]

Draw an arrow above the peak at the given retention time.

Parameters
  • figure (Figure)

  • axes (Axes)

  • rt (float) – Retention time in minutes.

  • intensity (float) – Peak apex height.

draw_peak_vlines(axes, rt, intensity, colour='red')[source]

Draw a vertical line to the apex of the peak at the given retention time.

Parameters
ylabel_sci_1dp(axes)[source]

Set matplotlib axes to use scientific notation (with math text and one decimal place).

Parameters

axes (Axes)

New in version 0.2.0.

ylabel_use_sci(axes)[source]

Set matplotlib axes to use scientific notation (with math text).

Parameters

axes (Axes)