spatialdata-plot icon indicating copy to clipboard operation
spatialdata-plot copied to clipboard

render_shapes() - problem with cmap alpha

Open roynov01 opened this issue 1 year ago • 4 comments
trafficstars

The alpha doesn't work for me, what am I missing? viridis = cm.get_cmap("viridis", 256) colors = viridis(np.linspace(0, 0.8, 256)) colors[0, :] = [1, 1, 1, 0] new_cmap = LinearSegmentedColormap.from_list("truncated_viridis", colors)

sdata_small.pl.render_images("Visium_HD_Mouse_Small_Intestine_full_image").pl.render_shapes( f"Visium_HD_Mouse_Small_Intestine_square_016um", color=gene_name, cmap=new_cmap).pl.show( coordinate_systems="global", title=gene_name, figsize=(10, 10))

image

The alpha doesn't work even when I use custon cmap with low alpha all over: image

roynov01 avatar Apr 22 '24 15:04 roynov01

I face the same mishap, and open one issue Cannot be shown in transparent colors when Plotting the gene expression data at SpatialData.

326416012-af230d86-2599-4988-9285-00fa62ac1a53

don't know why, but guess may be associate "clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255]for integers)"

Bioin-Mixologist avatar May 02 '24 10:05 Bioin-Mixologist

Hi, it looks like that the reason is that the fix from this PR https://github.com/scverse/spatialdata-plot/pull/239 didn't make it to a release yet. I will cut a release now.

LucaMarconato avatar May 02 '24 11:05 LucaMarconato

I made the release in pip, please let me know if this fixes your issue.

LucaMarconato avatar May 02 '24 11:05 LucaMarconato

Thankfully @LucaMarconato , after the update, it is now possible to display transparent colors.

pip install --upgrade spatialdata-plot==0.2.2

upgrade

However, i found exp maybe diiferent if chage get_cmap() follow the prompts, and prepare to open a new issue #255 .

The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use ''matplotlib.colormaps[name]'' or ''matplotlib.colormaps.get_cmap(obj)'' instead.
viridis= cm.get cmap("viridis",256)

newissue

Bioin-Mixologist avatar May 02 '24 13:05 Bioin-Mixologist

Thanks for opening the new issue, given that the reason for this issue has been solved I will be closing this one. Currently we are in the process of going through all issues with the repositories related to SpatialData so we will address your new issue:)

melonora avatar Jul 16 '24 10:07 melonora