Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 根据海生热图的复杂条件更改颜色_Python_Pandas_Matplotlib_Plot_Seaborn - Fatal编程技术网

Python 根据海生热图的复杂条件更改颜色

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

我已经生成了一张带有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','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)将所有单元格显示为黄色
谢谢。

看看这个。