scanpy.pl.MatrixPlot.add_totals

MatrixPlot.add_totals(show=True, sort=None, size=0.8, color=None)

Show barplot for the number of cells in in groupby category.

The barplot is by default shown on the right side of the plot or on top if the axes are swapped.

Parameters:
show : Optional[bool] (default: True)

Boolean to turn on (True) or off (False) ‘add_totals’

sort : Optional[Literal['ascending', 'descending']] (default: None)

Set to either ‘ascending’ or ‘descending’ to reorder the categories by cell number

size : Optional[float] (default: 0.8)

size of the barplot. Corresponds to width when shown on the right of the plot, or height when shown on top. The unit is the same as in matplotlib (inches).

color : Union[str, Tuple[float, ...], Sequence[Union[str, Tuple[float, ...]]], None] (default: None)

Color for the bar plots or list of colors for each of the bar plots. By default, each bar plot uses the colors assigned in adata.uns[{groupby}_colors].

Returns:

: BasePlot

Examples

>>> adata = sc.datasets.pbmc68k_reduced()
>>> markers = {'T-cell': 'CD3D', 'B-cell': 'CD79A', 'myeloid': 'CST3'}
>>> sc.pl.BasePlot(adata, markers, groupby='bulk_labels').add_totals().show()