@@ -157,6 +157,31 @@ def scatter( # noqa: PLR0913
157157 -------
158158 If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it.
159159
160+ Examples
161+ --------
162+ Plot two `.obs` annotations against each other and colour by a third.
163+
164+ .. plot::
165+ :context: close-figs
166+
167+ import scanpy as sc
168+ adata = sc.datasets.pbmc68k_reduced()
169+ sc.pl.scatter(adata, x="n_counts", y="n_genes", color="bulk_labels")
170+
171+ Plot expression of two genes against each other.
172+
173+ .. plot::
174+ :context: close-figs
175+
176+ sc.pl.scatter(adata, x="CD79A", y="CD3D", color="bulk_labels")
177+
178+ Use a precomputed embedding via the `basis` argument.
179+
180+ .. plot::
181+ :context: close-figs
182+
183+ sc.pl.scatter(adata, basis="umap", color="bulk_labels")
184+
160185 """
161186 # color can be a obs column name or a matplotlib color specification (or a collection thereof)
162187 if color is not None :
@@ -587,6 +612,27 @@ def ranking( # noqa: PLR0912, PLR0913
587612 -------
588613 Returns matplotlib gridspec with access to the axes.
589614
615+ Examples
616+ --------
617+ Show the genes with the highest loading on the first three principal components.
618+ PCA in :func:`~scanpy.datasets.pbmc68k_reduced` was computed on highly-variable
619+ genes only, so we subset to those genes before ranking.
620+
621+ .. plot::
622+ :context: close-figs
623+
624+ import scanpy as sc
625+ adata = sc.datasets.pbmc68k_reduced()
626+ adata_hv = adata[:, adata.var["highly_variable"]].copy()
627+ sc.pl.ranking(adata_hv, attr="varm", keys="PCs", indices=[0, 1, 2])
628+
629+ Include the lowest-loading genes alongside the highest.
630+
631+ .. plot::
632+ :context: close-figs
633+
634+ sc.pl.ranking(adata_hv, attr="varm", keys="PCs", indices=[0, 1, 2], include_lowest=True)
635+
590636 """
591637 if isinstance (keys , str ) and indices is not None :
592638 scores = getattr (adata , attr )[keys ][:, indices ]
0 commit comments