我有一个数据框 df
,其值从0到x(x为整数且没有固定值),在我的例子中x=10
我想用cmap 'Reds'映射热图,但是当数值为0时,不应该是白色而是绿色 '#009933'
import seaborn as sns # matplotlib inline
import random
data = []
for i in range(10):
data.append([random.randrange(0, 11, 1) for _ in range(10)])
df = pd.DataFrame(data)
fig, ax = plt.subplots(figsize = (12, 10))
# cmap = [????]
ax = sns.heatmap(df, cmap='Reds', linewidths = 0.005, annot = True, cbar=True)
plt.show()