Skip to content

Commit 525c94a

Browse files
authored
Fix double artist registration in render_labels and render_points (#634)
1 parent 18adeb9 commit 525c94a

10 files changed

Lines changed: 4 additions & 6 deletions

src/spatialdata_plot/pl/render.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ def _render_points(
10161016
elif method == "matplotlib":
10171017
# update axis limits if plot was empty before (necessary if datashader comes after)
10181018
update_parameters = not _mpl_ax_contains_elements(ax)
1019-
_cax = ax.scatter(
1019+
cax = ax.scatter(
10201020
adata[:, 0].X.flatten(),
10211021
adata[:, 1].X.flatten(),
10221022
s=render_params.size,
@@ -1029,7 +1029,6 @@ def _render_points(
10291029
zorder=render_params.zorder,
10301030
plotnonfinite=True, # nan points should be rendered as well
10311031
)
1032-
cax = ax.add_collection(_cax)
10331032
if update_parameters:
10341033
# necessary if points are plotted with mpl first and then with datashader
10351034
extent = get_extent(sdata_filt.points[element], coordinate_system=coordinate_system)
@@ -1721,7 +1720,7 @@ def _draw_labels(
17211720
outline_color=outline_color,
17221721
)
17231722

1724-
_cax = ax.imshow(
1723+
cax = ax.imshow(
17251724
labels,
17261725
rasterized=True,
17271726
cmap=None if categorical else render_params.cmap_params.cmap,
@@ -1730,9 +1729,8 @@ def _draw_labels(
17301729
origin="lower",
17311730
zorder=render_params.zorder,
17321731
)
1733-
_cax.set_transform(trans_data)
1734-
cax = ax.add_image(_cax)
1735-
return cax # noqa: RET504
1732+
cax.set_transform(trans_data)
1733+
return cax
17361734

17371735
# When color is a literal (col_for_color is None) and no explicit outline_color,
17381736
# use the literal color for outlines so they are visible (e.g., color='white' on
-2.21 KB
Loading
-3.87 KB
Loading
-4.4 KB
Loading
-4.07 KB
Loading
15.4 KB
Loading
4.78 KB
Loading
15.4 KB
Loading
874 Bytes
Loading
-509 Bytes
Loading

0 commit comments

Comments
 (0)