-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Labels
Description
saw this from @LucaMarconato tutorial on visium HD scverse/spatialdata-notebooks#93
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
# modify the viridis colormap, so that the top color is a green (better visible on the H&E pink), and such that
# the value 0 leads to a transparent color
viridis = cm.get_cmap("viridis", 256)
# using 0.8 instead of 1.0 truncates the colormap
colors = viridis(np.linspace(0, 0.8, 256))
# set the color of zero to be transparent
colors[0, :] = [1.0, 1.0, 1.0, 0.0]
new_cmap = LinearSegmentedColormap.from_list("truncated_viridis", colors)
it's actually really nice and result to this
I think it could just be an option to do this modification internally? with an argument like alpha_value_zero: bool = True
or so, wdyt?
LucaMarconato