Most of my values in pivotted lie between 0.96 and 1.. like 0.960186 0.960139 0.960129 etc.. I want them to be distinctishable.. but as some of my values are much more greater like 10, I did a double logarithmic colorscale.. But this doesn't help. Has someone an idea?
I did
p = sns.clustermap(pivotted, norm=SymLogNorm(linthresh=0.000000001, vmin=pivotted.min().min(), vmax=pivotted.max().max()))
You can try something like below, the trick is to set the boundaries at the lower values:
import seaborn as sns
import numpy as np
from matplotlib.colors import LogNorm
from matplotlib.colors import LinearSegmentedColormap
boundaries = [0.0, 0.03, 0.06, 0.09, 0.12,1.0]
hex_colors = sns.color_palette("coolwarm", n_colors=len(boundaries) * 2 + 2).as_hex()
hex_colors = [hex_colors[i] for i in range(0, len(hex_colors), 2)]
colors=list(zip(boundaries, hex_colors))
custom_color_map = LinearSegmentedColormap.from_list(
name="cus",
colors=colors,
)
You can also define a list of colors as long as the boundaries. So below i try to simulate data like yours, don't know how close it is:
np.random.seed(111)
df = np.random.uniform(low=0.8,high=1,size=(8,8))
df[np.random.randint(0,7,6),np.random.randint(0,7,6)] = 10,9,10,9,10,9
sns.clustermap(df,norm=LogNorm(),cmap=custom_color_map)