# Spatial Segment TypeError

**URL:** <https://discourse.scverse.org/t/spatial-segment-typeerror/1371>\
**Category:** squidpy\
**Created:** [May 2, 2023, 10:52am UTC](https://discourse.scverse.org/t/spatial-segment-typeerror/1371 "2023-05-02T10:52:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wing-kin-chan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/wing-kin-chan/32/643_2.png) [@Wing-kin-chan](https://discourse.scverse.org/u/Wing-kin-chan)\
**Post date:** [May 2, 2023, 10:52am UTC](https://discourse.scverse.org/t/spatial-segment-typeerror/1371/1 "2023-05-02T10:52:54Z")

</div>

Hi all!

Currently running:  
scanpy==1.9.3 anndata==0.9.1 umap==0.5.3 numpy==1.22.4 scipy==1.10.1 pandas==2.0.0 scikit-learn==1.2.2

I am attempting to visualise NanoString spatial transcriptomics using sq.pl.spatial\_segment() and am passing the usual arguments; adata, color, library\_key, and seg\_cell\_id. However, it is failing to overlay cell images onto the graphs and returning a type-error:

TypeError: ‘collection’ must be an instance of matplotlib.collections.Collection, not a matplotlib.image.AxesImage

 ![Untitled](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/1X/a6bfa59aa209d66fd19ef6f470425a3676cfc72f.png)

My guess is that it seems SquidPy is not passing the images onto the collection object when plotting multiple FOV’s and retaining it in an image container.

Has anyone encountered this error, and is there a fix?

Any help would much be appreciated. Thanks

---

<div class="post-metadata">

**Author:** ![MiTPenguin](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/mitpenguin/32/673_2.png) [@MiTPenguin](https://discourse.scverse.org/u/MiTPenguin)\
**Post date:** [May 24, 2023, 5:47pm UTC](https://discourse.scverse.org/t/spatial-segment-typeerror/1371/2 "2023-05-24T17:47:41Z")

</div>

I had this issue as well. Downgrading back down to matplotlib 3.5 solves the issue.

sq.pl in general is pretty broken. I believe the plan is to move all plotting functionality to the authors’ new package SpatialData. Until we get a robustly documented SD package it’s all going to be pretty touch and go.
