2024-09-30 06:15:54 发布
网友
数据透视中的大多数值都在0.96和1之间。。喜欢 0.960186 0.960139 0.960129 等我希望它们是可识别的。。但由于我的一些值更大,比如10,我做了一个双对数色标。。但这没用。有人有主意吗
是的
p = sns.clustermap(pivotted, norm=SymLogNorm(linthresh=0.000000001, vmin=pivotted.min().min(), vmax=pivotted.max().max()))
您可以尝试以下方法,诀窍是将边界设置为较低的值:
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, )
您还可以定义一个颜色列表,其长度与边界相同。因此,下面我尝试模拟像您这样的数据,不知道它有多接近:
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)
您可以尝试以下方法,诀窍是将边界设置为较低的值:
您还可以定义一个颜色列表,其长度与边界相同。因此,下面我尝试模拟像您这样的数据,不知道它有多接近:
相关问题 更多 >
编程相关推荐