import matplotlib.pyplot as plt import numpy as np from matplotlib.colors import LinearSegmentedColormap # 自定义颜色映射 colors = [(0, 0, 0), (1, 1, 1), (0.5, 0, 0.5)] # RGB颜色值 cmap_name = 'custom_cmap' cm = LinearSegmentedColormap.from_list(cmap_name, colors, N=100) # ...
print(cmap2.N) # 绘制热力图,分别使用两种不同的颜色映射 fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 6)) sns.heatmap(data, cmap=cmap, annot=True, fmt=".2f", ax=ax1) ax1.set_title("Linear segmented colormap") sns.heatmap(data, cmap=cmap2, norm=norm, annot=True, fm...