From 8674134cdb6c4c05cc52a815d42e7fed3c1ce942 Mon Sep 17 00:00:00 2001 From: Manuel Lubetzki Date: Fri, 22 Aug 2025 15:37:09 +0200 Subject: [PATCH] Ignore NaNs when calculating scatter plot dot size --- src/scanpy/plotting/_tools/scatterplots.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scanpy/plotting/_tools/scatterplots.py b/src/scanpy/plotting/_tools/scatterplots.py index df5e68fa37..04243a3128 100644 --- a/src/scanpy/plotting/_tools/scatterplots.py +++ b/src/scanpy/plotting/_tools/scatterplots.py @@ -227,7 +227,8 @@ def embedding( # noqa: PLR0912, PLR0913, PLR0915 ): size = np.array(size, dtype=float) else: - size = 120000 / adata.shape[0] + # if the basis has NaNs, ignore the corresponding cells for size calcluation + size = 120000 / (~np.isnan(basis_values).any(axis=1)).sum() ########## # Layout #