Skip to content

TypeError: scatter() got an unexpected keyword argument 'colorbar_loc' #3893

@Dawntown

Description

@Dawntown

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the main branch of scanpy.

What happened?

Virtual env managed by micromamba
Python version: 3.11
Scanpy version: 1.11.5 (conda-forge installed or pip installed)

I am using sc.pl.scatter to plot a scatter of two genes coloured by a continuous variable (time) but do not want the colorbar shown beside.

sc.pl.scatter(ad, x=g1, y=g2, color='t', colorbar_loc=None)
# or plot on a existing ax
sc.pl.scatter(ad, x=g1, y=g2 color='t', show=False, colorbar_loc=None, ax=axes[i, j])

The same error arises

File ~/Garage/micromamba/envs/pl/lib/python3.11/site-packages/legacy_api_wrap/__init__.py:82, in legacy_api.<locals>.wrapper.<locals>.fn_compatible(*args_all, **kw)
     79 @wraps(fn)
     80 def fn_compatible(*args_all: P.args, **kw: P.kwargs) -> R:
     81     if len(args_all) <= n_positional:
---> 82         return fn(*args_all, **kw)
     84     args_pos: P.args
     85     args_pos, args_rest = args_all[:n_positional], args_all[n_positional:]

TypeError: scatter() got an unexpected keyword argument 'colorbar_loc'

I have checked and followed the newest document of scanpy: https://scanpy.readthedocs.io/en/stable/generated/scanpy.pl.scatter.html, and I found there is indeed no colorbar_loc in the function's usage but it appears in explanation of Parameters.

Image

Minimal code sample

# /// script
# requires-python = "==3.11"
# dependencies = [
#   "scanpy@git+https://github.com/scverse/scanpy.git@main",
# ]
# ///
#
# This script automatically imports the development branch of scanpy to check for issues

import scanpy as sc
adata = sc.datasets.pbmc3k()
adata.obs['t'] = adata.X.toarray().sum(axis=1)
sc.pl.scatter(adata, x='MIR1302-10', y='FAM138A', color='t', colorbar_loc=None)

Error output

File ~/Garage/micromamba/envs/pl/lib/python3.11/site-packages/legacy_api_wrap/__init__.py:82, in legacy_api.<locals>.wrapper.<locals>.fn_compatible(*args_all, **kw)
     79 @wraps(fn)
     80 def fn_compatible(*args_all: P.args, **kw: P.kwargs) -> R:
     81     if len(args_all) <= n_positional:
---> 82         return fn(*args_all, **kw)
     84     args_pos: P.args
     85     args_pos, args_rest = args_all[:n_positional], args_all[n_positional:]

TypeError: scatter() got an unexpected keyword argument 'colorbar_loc'

Versions

pandas	2.3.0 (2.3.2)
numpy	2.2.6
matplotlib	3.10.3 (3.10.6)
seaborn	0.13.2
scanpy	1.11.5
anndata	0.12.1
scipy	1.15.2
joblib	1.5.1 (1.5.2)
----	----
pyparsing	3.2.3 (3.2.5)
pure_eval	0.2.3
pynndescent	0.5.13
texttable	1.7.0
zarr	3.1.3
decorator	5.2.1
kiwisolver	1.4.8 (1.4.9)
charset-normalizer	3.4.2
argcomplete	3.6.3
pyarrow	20.0.0
parso	0.8.4
cycler	0.12.1
executing	2.2.0
prompt_toolkit	3.0.51
stack_data	0.6.3
python-dateutil	2.9.0.post0
psutil	7.0.0
ipython	9.3.0
h5py	3.12.1
typing_extensions	4.14.0
cffi	1.17.1
legacy-api-wrap	1.4.1
natsort	8.4.0
igraph	1.0.0
Pygments	2.19.2
patsy	1.0.1
colorama	0.4.6
asttokens	3.0.0
session-info2	0.1.2
numba	0.61.2
jupyter_core	5.8.1
scikit-learn	1.7.2
tqdm	4.67.1
numcodecs	0.16.1
appnope	0.1.4
traitlets	5.14.3
umap-learn	0.5.7
pycparser	2.22
fsspec	2025.5.1
pytz	2025.2
plotly	6.1.2
debugpy	1.8.14
wcwidth	0.2.13
jedi	0.19.2
matplotlib-inline	0.1.7
ipykernel	6.29.5
tornado	6.5.1
threadpoolctl	3.6.0
statsmodels	0.14.5
defusedxml	0.7.1
leidenalg	0.11.0
packaging	25.0
comm	0.2.2
crc32c	2.7.1
donfig	0.8.1.post1
pyzmq	27.0.0
llvmlite	0.44.0
setuptools	80.9.0
pillow	11.2.1 (11.3.0)
ipywidgets	8.1.8
zstandard	0.23.0
msgpack	1.1.1
PyYAML	6.0.2
six	1.17.0
platformdirs	4.3.8
jupyter_client	8.6.3
----	----
Python	3.11.13 | packaged by conda-forge | (main, Jun  4 2025, 14:52:34) [Clang 18.1.8 ]
OS	macOS-15.5-arm64-arm-64bit
CPU	8 logical CPU cores, arm
GPU	No GPU found
Updated	2025-11-13 05:06

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions