grassp.pl.ternary

Contents

grassp.pl.ternary#

ternary(adata, color=None, ax=None, labels=None, show=True, colorbar_loc=None, legend_loc=None, legend_fontweight=None, legend_fontsize=None, legend_fontoutline=None, na_in_legend=None, **kwargs)[source]#

Scatter plot of 3-part compositions in a ternary diagram.

The function expects that adata.X has exactly three columns which represent the proportions of each component and therefore should sum to 1 (or all share the same unit).

Parameters:
adata AnnData

AnnData with three variables (columns). Observations are plotted as points in barycentric (ternary) coordinates.

color Optional[str] (default: None)

Key passed to Scanpy’s color utilities (e.g. column in adata.obs or layer key). If None the default color cycle is used.

ax default: None

Existing mpltern axes. If None a new ternary subplot is created.

labels Optional[List[str]] (default: None)

Axis labels for the three corners. Defaults to adata.var_names.

show bool (default: True)

Whether to immediately display the plot.

colorbar_loc Optional[str] (default: None)

Location argument forwarded to matplotlib.pyplot.colorbar() when color is continuous.

legend_loc Optional[str] (default: None)

Location string for the categorical legend.

legend_fontweight Optional[str] (default: None)

Weight of legend text.

legend_fontsize Optional[int] (default: None)

Size of legend text.

legend_fontoutline Optional[str] (default: None)

Outline colour for legend text.

na_in_legend Optional[bool] (default: None)

Whether to show a legend entry for NaN values.

**kwargs

Additional keyword arguments passed to matplotlib.axes.Axes.scatter().

Returns:

If show is False, returns the Ternary axes containing the scatter plot.