scanpy.pl.draw_graph

scanpy.pl.draw_graph(adata, basis, *, color=None, gene_symbols=None, use_raw=None, sort_order=True, edges=False, edges_width=0.1, edges_color='grey', arrows=False, arrows_kwds=None, groups=None, components=None, layer=None, projection='2d', color_map=None, palette=None, size=None, frameon=None, legend_fontsize=None, legend_fontweight='bold', legend_loc='right margin', legend_fontoutline=None, ncols=4, hspace=0.25, wspace=None, title=None, show=None, save=None, ax=None, return_fig=None, **kwargs)

Scatter plot in graph-drawing basis.

Parameters
adata : AnnDataAnnData

Annotated data matrix.

color : str, Sequence[str], NoneUnion[str, Sequence[str], None]

Keys for annotations of observations/cells or variables/genes, e.g., 'ann1' or ['ann1', 'ann2'].

gene_symbols : str, NoneOptional[str]

Column name in .var DataFrame that stores gene symbols. By default var_names refer to the index column of the .var DataFrame. Setting this option allows alternative names to be used.

use_raw : bool, NoneOptional[bool]

Use .raw attribute of adata for coloring with gene expression. If None, defaults to True if layer isn’t provided and adata.raw is present.

layer : str, NoneOptional[str]

Name of the AnnData object layer that wants to be plotted. By default adata.raw.X is plotted. If use_raw=False is set, then adata.X is plotted. If layer is set to a valid layer name, then the layer is plotted. layer takes precedence over use_raw.

layout : {'fa', 'fr', 'drl', ..}, optional (default: last computed)

One of the draw_graph layouts, see draw_graph(). By default, the last computed layout is used.

edges : boolbool

Show edges.

edges_width : floatfloat

Width of edges.

edges_color : matplotlib color(s), optional (default: 'grey')

Color of edges. See draw_networkx_edges().

arrows : boolbool

Show arrows (requires to run rna_velocity() before).

arrows_kwds : Mapping, NoneOptional[Mapping[str, Any]]

Passed to quiver()

sort_order : boolbool

For continuous annotations used as color parameter, plot data points with higher values on top of others.

groups : str, NoneOptional[str]

Restrict to a few categories in categorical observation annotation. The default is not to restrict to any groups.

components : str, Sequence[str], NoneUnion[str, Sequence[str], None]

For instance, ['1,2', '2,3']. To plot all available components use components='all'.

projection : {'2d', '3d'}, optional (default: '2d')

Projection of plot.

legend_loc : strstr

Location of legend, either ‘on data’, ‘right margin’ or valid keywords for matplotlib.legend.

legend_fontsize : int, NoneOptional[int]

Legend font size.

legend_fontweight : {‘normal’, ‘bold’, …}, optional (default: None)

Legend font weight. Defaults to ‘bold’ if legend_loc == 'on data', otherwise to ‘normal’. Available are ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black'].

legend_fontoutline : int, NoneOptional[int]

Linewidth of the legend font outline. This uses matplotlib.patheffects to draw a white outline around the legend text.

size : float, NoneOptional[float]

Point size. If None, is automatically computed.

color_map : Colormap, str, NoneUnion[Colormap, str, None]

Color map to use for continous variables. Anything that works for cmap argument of pyplot.scatter should work here (e.g. "magma", "viridis", mpl.cm.cividis). If None value of mpl.rcParams["image.cmap"] is used.

palette : str, Sequence[str], Cycler, NoneUnion[str, Sequence[str], Cycler, None]

Colors to use for plotting categorical annotation groups. The palette can be a valid matplotlib.pyplot.colormap name like 'Set2' or 'tab20', a list of colors like ['red', '#ccdd11', (0.1, 0.2, 1)] or a Cycler object. If None, mpl.rcParams["axes.prop_cycle"] is used unless the categorical variable already has colors stored in adata.uns["{var}_colors"]. If provided, values of adata.uns["{var}_colors"] will be set by this palette.

frameon : bool, NoneOptional[bool]

Draw a frame around the scatter plot. Defaults to value set in set_figure_params(), defaults to True.

ncols : intint

Number of panels per row.

wspace : float, NoneOptional[float]

Adjust the width of the space between multiple panels.

hspace : floatfloat

Adjust the height of the space between multiple panels.

title : str, Sequence[str], NoneUnion[str, Sequence[str], None]

Provide title for panels either as string or list of strings, e.g. ['title1', 'title2', ...].

kwargs : further keyword arguments, optional

Arguments to pass to matplotlib.pyplot.scatter(), for instance: the maximum and minimum values (e.g. vmin=-2, vmax=5).

return_fig : bool, NoneOptional[bool]

Return the matplotlib figure.

show : bool, NoneOptional[bool]

Show the plot, do not return axis.

save : bool, str, NoneUnion[bool, str, None]

If True or a str, save the figure. A string is appended to the default filename. Infer the filetype if ending on {‘.pdf’, ‘.png’, ‘.svg’}.

ax : Axes, NoneOptional[Axes]

A matplotlib axes object. Only works if plotting a single component.

Return type

Figure, Axes, NoneUnion[Figure, Axes, None]

Returns

If show==False a Axes or a list of it.