我正在尝试使用 seaborn 绘制热图。我的值从 0 到 5,我需要制作一个蓝色到红色的色阶,白色为 1,蓝色为 1 以下,红色为 1 到 5。
我该怎么做?
import seaborn as sns; sns.set()
hm=sns.heatmap(proportion, vmin=0, vmax=5, cmap='RdBu')
这是我尝试做的,但不是定制的……“比例”是我的变量。有什么我可以做的吗?
最佳答案
也许你的意思是使用center
参数,
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
data = np.random.rand(10,10)*5
ax = sns.heatmap(data, vmin=0,vmax=5,center=1,cmap="RdBu_r")
plt.show()
关于python - 如何将颜色条以 seaborn 热图的定义值居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48589567/