Python 根据海生热图的复杂条件更改颜色
我已经生成了一张带有seaborn的热图,代码如下:Python 根据海生热图的复杂条件更改颜色,python,pandas,matplotlib,plot,seaborn,Python,Pandas,Matplotlib,Plot,Seaborn,我已经生成了一张带有seaborn的热图,代码如下: import seaborn as sns import matplotlib.pylab as plt a4_dims = (25, 15) fig, ax = plt.subplots(figsize=a4_dims) cmap_adeguati = mpl.cm.get_cmap('Greens', 1) matrix_data = transition_matrix_cpc.groupby(['CLASSE_ANTE','CLA
import seaborn as sns
import matplotlib.pylab as plt
a4_dims = (25, 15)
fig, ax = plt.subplots(figsize=a4_dims)
cmap_adeguati = mpl.cm.get_cmap('Greens', 1)
matrix_data = transition_matrix_cpc.groupby(['CLASSE_ANTE','CLASSE_POST'],as_index=False)['UNITA'].count().pivot('CLASSE_ANTE','CLASSE_POST','UNITA').fillna(0)
ax = sns.heatmap(matrix_data, mask=matrix_data==0, linewidth=0.5, annot = True, fmt='g')
plt.show()
结果是:
现在我想换一种颜色,例如:
- 绿色显示所有带(索引>列)和(列<10)的单元格
- 浅绿色所有单元格,带(列>索引)和(列<10)
- 用(列>索引)和(列>10)红色标记所有单元格
- 用(索引>列)和(列>10)将所有单元格显示为黄色