Repository navigation
Maximum for cbar in render_shapes is too high with spatialdata_plot==0.3.0 #559
Copy link
Copy link
Closed
Copy link
Description
Report
Hi, first of all thanks for releasing the newest version of spatialdata_plot, really cool to see all the improvements! One thing I noticed with 0.3.0 is that the colorbar in render_shapes now extends too far. Consider one of the spatialdata example datasets:
# download data
! wget https://s3.embl.de/spatialdata/spatialdata-sandbox/xenium_2.0.0_io_spatialdata_0.7.1.zip
# unzipping the file
import zipfile
with zipfile.ZipFile('xenium_2.0.0_io_spatialdata_0.7.1.zip', 'r') as zip_ref:
zip_ref.extractall('xenium_sdata')
# data loading
import spatialdata as sd
import spatialdata_plot
print(spatialdata_plot.__version__) # 0.3.0
sdata = sd.read_zarr('xenium_sdata/data.zarr')
# linking table and shapes
sdata.tables["table"].obs["region"] = 'cell_boundaries'
sdata.set_table_annotates_spatialelement("table", region='cell_boundaries')
# getting the maximum transcript count
print(sdata.tables['table'].obs['transcript_counts'].max()) # 549
# plotting the shapes
sdata.pl.render_shapes('cell_boundaries', color='transcript_counts').pl.show()
Here, the cbar extends until >800, even though the maximum number of transcripts is 549.
This works fine with the previous version of spatialdata_plot, so I assume one of the recent changes broke something.
Versions
pandas 2.3.1
spatialdata 0.7.2
spatialdata-plot 0.3.0
---- ----
typing_extensions 4.14.1
jaraco.text 3.12.1
traitlets 5.14.3
xarray-dataclass 3.0.0
donfig 0.8.1.post1
prompt_toolkit 3.0.51
annsel 0.1.2
packaging 25.0
wcwidth 0.2.13
jupyter_client 8.6.3
debugpy 1.8.16
crc32c 2.8
jupyter_core 5.8.1
spatial_image 1.2.3
psutil 7.2.2
texttable 1.7.0
pytz 2025.2
locket 1.0.0
decorator 5.2.1
pyct 0.5.0
shapely 2.1.1
idna 3.10
platformdirs 4.3.8
igraph 0.11.9
ome-zarr 0.12.2
attrs 25.3.0
PyYAML 6.0.2
anndata 0.12.8
pyarrow 21.0.0
legacy-api-wrap 1.4.1
defusedxml 0.7.1
matplotlib 3.10.5
wrapt 1.17.2
tqdm 4.67.1
ipykernel 6.30.1
networkx 3.5
numcodecs 0.15.1
msgpack 1.1.2
plotly 6.3.1
dask 2026.1.1
narwhals 2.16.0
jaraco.context 5.3.0
pycparser 2.23
MarkupSafe 3.0.2
multipledispatch 1.0.0 (0.6.0)
tornado 6.5.1
natsort 8.4.0
matplotlib-inline 0.1.7
threadpoolctl 3.6.0
stack-data 0.6.3
pooch 1.8.2 (v1.8.2)
google-crc32c 1.8.0
dask-image 2024.5.3
pyparsing 3.2.3
session-info2 0.2
setuptools 80.9.0
matplotlib-scalebar 0.9.0
distributed 2026.1.1
jedi 0.19.2
charset-normalizer 3.4.2
cuda-pathfinder 1.4.0 (12.9.4)
zarr 3.1.5
toolz 1.0.0
datashader 0.18.1
coverage 7.10.2
fsspec 2025.7.0
fast-array-utils 1.3.1
Pygments 2.19.2
dask-geopandas 0.5.0
executing 2.2.0
multiscale_spatial_image 2.0.3
parso 0.8.4
scikit-image 0.25.2
click 8.2.1
geopandas 1.1.1
six 1.17.0
certifi 2025.8.3 (2025.08.03)
h5py 3.14.0
more-itertools 10.8.0
cycler 0.12.1
jaraco.functools 4.0.1
python-dateutil 2.9.0.post0
comm 0.2.3
scikit-learn 1.7.1
zict 3.0.0
cloudpickle 3.1.1
cuda-bindings 12.9.4
requests 2.32.4
scanpy 1.11.4
Deprecated 1.2.18
kiwisolver 1.4.8
pure_eval 0.2.3
pathlib_abc 0.5.2
urllib3 2.5.0
xarray 2025.12.0
cffi 2.0.0
llvmlite 0.44.0
joblib 1.5.1
numba 0.61.2
rich 14.1.0
numpy 2.2.6
Jinja2 3.1.6
lazy_loader 0.4
param 2.2.1
pyzmq 27.0.1
leidenalg 0.10.2
tblib 3.2.2
ipython 9.4.0
pillow 11.3.0
sparse 0.18.0
xarray-spatial 0.4.0
jaraco.collections 5.1.0
pyproj 3.7.1
sortedcontainers 2.4.0
asttokens 3.0.0
universal_pathlib 0.3.8
scipy 1.16.1
---- ----
Python 3.13.5 (main, Jul 23 2025, 00:37:22) [Clang 20.1.4 ]
OS Linux-5.14.0-611.36.1.el9_7.x86_64-x86_64-with-glibc2.35
Updated 2026-03-25 16:17Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
timtreis commentedon Mar 25, 2026
Weird! Could you try using
matplotlibexplicitly for the plotting backend? I'm worried that datashader might've triggered and aggregated points beyond the raw range (now silent because of the change in logging ;) )MeyerBender commentedon Mar 25, 2026
Good call, with matplotlib it does work as expected.
timtreis commentedon Mar 25, 2026
Okay, then it's likely that datashader defaults to
sumaggregation right now. Will investigate and ponder what the best idea there isFix shapes datashader colorbar exceeding data range (#559)
Fix shapes datashader colorbar exceeding data range (#559)
Fix shapes datashader colorbar exceeding data range (#559)
timtreis commentedon Mar 27, 2026
Hey @MeyerBender, there was actually another underlying bug. I'll make the 0.3.1 release now, could you try with your usecase?