@@ -176,6 +176,31 @@ def scatter( # noqa: PLR0913
176176 -------
177177 If `show==False` a :class:`~matplotlib.axes.Axes` or a list of it.
178178
179+ Examples
180+ --------
181+ Plot two `.obs` annotations against each other and colour by a third.
182+
183+ .. plot::
184+ :context: close-figs
185+
186+ import scanpy as sc
187+ adata = sc.datasets.pbmc68k_reduced()
188+ sc.pl.scatter(adata, x="n_counts", y="n_genes", color="bulk_labels")
189+
190+ Plot expression of two genes against each other.
191+
192+ .. plot::
193+ :context: close-figs
194+
195+ sc.pl.scatter(adata, x="CD79A", y="CD3D", color="bulk_labels")
196+
197+ Use a precomputed embedding via the `basis` argument.
198+
199+ .. plot::
200+ :context: close-figs
201+
202+ sc.pl.scatter(adata, basis="umap", color="bulk_labels")
203+
179204 """
180205 # color can be a obs column name or a matplotlib color specification (or a collection thereof)
181206 if color is not None :
@@ -618,6 +643,27 @@ def ranking( # noqa: PLR0912, PLR0913
618643 -------
619644 Returns matplotlib gridspec with access to the axes.
620645
646+ Examples
647+ --------
648+ Show the genes with the highest loading on the first three principal components.
649+ PCA in :func:`~scanpy.datasets.pbmc68k_reduced` was computed on highly-variable
650+ genes only, so we subset to those genes before ranking.
651+
652+ .. plot::
653+ :context: close-figs
654+
655+ import scanpy as sc
656+ adata = sc.datasets.pbmc68k_reduced()
657+ adata_hv = adata[:, adata.var["highly_variable"]].copy()
658+ sc.pl.ranking(adata_hv, attr="varm", keys="PCs", indices=[0, 1, 2])
659+
660+ Include the lowest-loading genes alongside the highest.
661+
662+ .. plot::
663+ :context: close-figs
664+
665+ sc.pl.ranking(adata_hv, attr="varm", keys="PCs", indices=[0, 1, 2], include_lowest=True)
666+
621667 """
622668 if isinstance (keys , str ) and indices is not None :
623669 scores = getattr (adata , attr )[keys ][:, indices ]
0 commit comments