var_by_distance#

squidpy.pl.var_by_distance(adata, *, var, anchor_key, design_matrix_key='design_matrix', stack_vars=False, covariate=None, order=5, show_scatter=True, color=None, line_palette=None, scatter_palette='viridis', dpi=None, figsize=None, save=None, title=None, axis_label=None, return_ax=None, regplot_kwargs=mappingproxy({}), scatterplot_kwargs=mappingproxy({}))[source]#

Plot a variable using a smooth regression line with increasing distance to an anchor point.

Parameters:
adata AnnData

Annotated data object.

var str | list[str]

Variables to plot on y-axis.

anchor_key str | list[str]

Anchor point column from which distances are taken.

design_matrix_key str (default: 'design_matrix')

Name of the design matrix, previously computed with squidpy.tl.var_by_distance(), to use.

stack_vars bool (default: False)

Whether to show multiple variables on the same plot. Only works if ‘covariate’ is not specified.

covariate str | None (default: None)

A covariate for which separate regression lines are plotted for each category.

order int (default: 5)

Order of the polynomial fit for seaborn.regplot().

show_scatter bool (default: True)

Whether to show a scatter plot underlying the regression line.

color str | None (default: None)

Variables in adata.obs to plot if ‘show_scatter==True’.

line_palette str | Sequence[str] | Cycler | None (default: None)

Categorical color palette used in case a covariate is specified.

scatter_palette str | Sequence[str] | Cycler | None (default: 'viridis')

Color palette for the scatter plot underlying the seaborn.regplot().

dpi int | None (default: None)

Dots per inch.

figsize tuple[int, int] | None (default: None)

Size of the figure in inches.

save str | Path | None (default: None)

Whether to save the plot.

title str | None (default: None)

Panel titles.

axis_label str | None (default: None)

Panel axis labels.

return_ax bool | None (default: None)

Whether to return matplotlib.axes.Axes object(s).

regplot_kwargs Mapping[str, Any] (default: mappingproxy({}))

Kwargs for seaborn.regplot().

scatterplot_kwargs Mapping[str, Any] (default: mappingproxy({}))

Kwargs for matplotlib.pyplot.scatter().

Returns:

Axes | None – Nothing, just plots the figure and optionally saves the plot.