mgkit.plots.abund module

New in version 0.1.15.

Module to plot relative abundances in a 1D or 3D projection

mgkit.plots.abund.col_func_firstel(key, colors=None)
mgkit.plots.abund.col_func_name(key, func=None, colors=None)
mgkit.plots.abund.col_func_taxon(taxon_id, taxonomy, anc_ids, colpal)
mgkit.plots.abund.draw_1d_grid(ax, labels=['LAM', 'SAM'], fontsize=22)

Changed in version 0.2.0: reworked internals and changed defaults

Draws a 1D axis, to display propotions.

Parameters:
  • ax – an axis instance
  • labels (iterable) – list of string to be put for the axes
  • fontsize (float) – font size for the labels, the tick font size is equal to 0.75 * fontsize
mgkit.plots.abund.draw_axis_internal_triangle(ax, color='r', linewidth=2.0)

New in version 0.2.5.

Draws a triangle that indicates the 50% limit for all 3 samples

Parameters:
  • ax – axis to use
  • color (str, float, tuple) – color used to draw the triangle
  • linewidth (float) – line width
mgkit.plots.abund.draw_circles(ax, data, col_func=<function col_func_name>, csize=200, alpha=0.5, sizescale=None, order=None, linewidths=0.0, edgecolor='none')

Changed in version 0.2.0: changed internals and added return value

Draws a scatter plot over either a planar-simplex projection, if the number of coordinates is 3, or in a 1D axis.

If the number of coordinates is 3, project_point() is used to project the point in 2 coordinates. The coordinates are converted in proportions internally.

Parameters:
  • ax – axis to plot on
  • data (pandas.DataFrame) – a DataFrame with 2 for a 1D plot or 3 columns for a planar-simplex
  • col_func (func) – a function that accept a parameter, an element of the DataFrame index and returns a colour for it
  • csize (int) – the base size of the circles
  • alpha (float) – transparency of the circles, between 0 and 1 included
  • sizescale (None, pandas.Series) – a Series or dictionary with the same elements as the Index of data, whose values are the size factors that are multiplied to csize. If None, the size of the circles is equal to csize
  • order (None, iterable) – iterable with the elements of data Index, to specify the order in which the circles must be plotted. If None, the order is the same as data.index
  • linewidths (float) – width of the circle line
  • edgecolor (str) – color of the circle line
Returns:

the return value of matplotlib scatter

Return type:

PathCollection

Note

To not have circle lines, edgecolor must be ‘none’ and linewidths equal 0

mgkit.plots.abund.draw_triangle_grid(ax, labels=['LAM', 'SAM', 'EAM'], linewidth=1.0, styles=['-', ':', '--'], fontsize=22)

Changed in version 0.2.0: reworked internals and changed defaults

Draws a triangle as axes, for a planar-simplex projection.

Parameters:
  • ax – an axis instance
  • labels (iterable) – list of string to be put for the axes
  • styles (None, iterable) – either None for solid lines or matplotlib line markers. These are in sync between the internal lines and the axes.
  • linewidth (float) – line width for the axes, the internal lines are equal to 0.75 * linewidth
  • fontsize (float) – font size for the labels, the tick font size is equal to 0.75 * fontsize
mgkit.plots.abund.project_point(point)

Project a tuple containing coordinates (i.e. x, y, z) to planar-simplex.

Parameters:point (tuple) – contains the three coordinates to project
Returns:the projected point in a planar-simplex
Return type:tuple