From 3b82349438d8156b33bd2989c230903a9a7a209e Mon Sep 17 00:00:00 2001 From: Ekin-Kahraman Date: Sat, 11 Apr 2026 16:25:51 +0100 Subject: [PATCH] docs: add inline example plot to sc.pl.pca_variance_ratio Part of #1664. Adds rendered plot examples showing the PCA variance ratio on PBMC 3k data, including the log scale variant. --- src/scanpy/plotting/_tools/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/scanpy/plotting/_tools/__init__.py b/src/scanpy/plotting/_tools/__init__.py index 9bd6fb1494..f0efe00f4a 100644 --- a/src/scanpy/plotting/_tools/__init__.py +++ b/src/scanpy/plotting/_tools/__init__.py @@ -202,6 +202,24 @@ def pca_variance_ratio( A string is appended to the default filename. Infer the filetype if ending on {`'.pdf'`, `'.png'`, `'.svg'`}. + Examples + -------- + Plot the variance ratio for the first 30 PCs. + + .. plot:: + :context: close-figs + + import scanpy as sc + adata = sc.datasets.pbmc3k_processed() + sc.pl.pca_variance_ratio(adata) + + Plot on a logarithmic scale. + + .. plot:: + :context: close-figs + + sc.pl.pca_variance_ratio(adata, log=True) + """ ranking( adata,