squidpy.pl.var_by_distance(adata, var, anchor_key, design_matrix_key='design_matrix', color=None, covariate=None, order=5, show_scatter=True, 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.

  • adata (AnnData) – Annotated data object.

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

  • var (str | list[str]) – Variables to plot on y-axis.

  • anchor_key (str | list[str]) – Anchor point column from which distances are taken.

  • color (Optional[str]) – Variables to plot on color palette.

  • covariate (Optional[str]) – A covariate for which separate regression lines are plotted for each category.

  • order (int) – Order of the polynomial fit for seaborn.regplot().

  • show_scatter (bool) – Whether to show a scatter plot underlying the regression line.

  • line_palette (Union[str, Sequence[str], Cycler, None]) – Categorical color palette used in case a covariate is specified.

  • scatter_palette (Union[str, Sequence[str], Cycler, None]) – Color palette for the scatter plot underlying the sns.regplot

  • figsize (Optional[tuple[int, int]]) – Size of the figure in inches.

  • dpi (Optional[int]) – Dots per inch.

  • save (Union[str, Path, None]) – Whether to save the plot.

  • scalebar_kwargs – Keyword arguments for matplotlib_scalebar.ScaleBar().

  • edges_kwargs – Keyword arguments for networkx.draw_networkx_edges().

  • kwargs – Keyword arguments for matplotlib.pyplot.scatter() or matplotlib.pyplot.imshow().

  • title (Optional[str]) – Panel titles.

  • axis_label (Optional[str]) – Panel axis labels.

  • regplot_kwargs (Mapping[str, Any]) – Kwargs for sns.regplot

  • scatterplot_kwargs (Mapping[str, Any]) – Kwargs for sns.scatter

Return type:



: Nothing, just plots the figure and optionally saves the plot.