scirpy.pl.embedding#
- scirpy.pl.embedding(adata, basis, *, color=None, panel_size=(4, 4), palette=None, legend_loc='right margin', ax=None, ncols=3, show=False, hspace=0.25, wspace=None, **kwargs)#
A customized wrapper to the
scanpy.pl.embedding()function.- The differences to the scanpy embedding function are:
allows to specify a
panel_sizeAllows to specify a different
basis,legend_locandpalettefor each panel. The number of panels is defined by thecolorparameter.Use a patched version for adding “on data” labels. The original raises a flood of warnings when coords are
nan.For columns with many categories, cycles through colors instead of reverting to grey
allows to specify axes, even if multiple colors are set.
- Parameters:
adata (
AnnData) – annotated data matrixbasis (
str) – embedding to plot. Get the coordinates from the “X_{basis}” key inadata.obsm. This can be a list of the same length ascolorto specify different bases for each panel.color (
Union[Sequence[str],str,None] (default:None)) – Keys for annotations of observations/cells or variables/genes, e.g.,'ann1'or['ann1', 'ann2'].panel_size (
tuple[float,float] (default:(4, 4))) – Size tuple (width,height) of a single panel in inchespalette (
Union[str,Cycler,Sequence[str],Sequence[Cycler],None] (default:None)) – Colors to use for plotting categorical annotation groups. The palette can be a validListedColormapname ('Set2','tab20', …) or aCyclerobject. It is possible to specify a list of the same size ascolorto choose a different color map for each panel.legend_loc (
str(default:'right margin')) – Location of legend, either'on data','right margin'or a valid keyword for thelocparameter ofLegend.ax (
Union[Axes,Sequence[Axes],None] (default:None)) – A matplotlib axes object or a list with the same length ascolorthereof.ncols (
int(default:3)) – Number of columns for multi-panel plotsshow (
Optional[bool] (default:False)) – If True, show the firgure. If false, return a list of Axes objectswspace (
Optional[float] (default:None)) – Adjust the width of the space between multiple panels.hspace (
float(default:0.25)) – Adjust the height of the space between multiple panels.**kwargs – Arguments to pass to
scanpy.pl.embedding().
- Return type:
- Returns:
axes A list of axes objects, containing one element for each
color, or None ifshow == True.
See also