简体   繁体   English

为熊猫数据框中的每一行创建热图

[英]create heatmap for each row in pandas dataframe

Below is a df called "compmatrix": 下面是一个称为“ commatrix”的df:

             -3.0        -5.0       -7.0    
Gain/DD*DD%  0.009000    0.034000   0.088000    
Gain/Expsr%  0.487000    0.927000   1.628000    
Gain/MaxDD   0.015000    0.021000   0.025000    
MaxDD*iBeta  32.633      193.536    856.520

I'd like to apply a heatmap to each row (vs. the whole dataframe), because of the big difference in values. 我想将热图应用于每一行(相对于整个数据框),因为值存在很大差异。

import seaborn as sns
sns.heatmap(compmatrix,cmap='RdYlGn_r',annot=True)

but the fact that there's no axis=1 has thrown me off. 但是没有axis = 1的事实使我失望。 Can't seem to find the solution I'm looking for in the documentation. 似乎无法在文档中找到所需的解决方案。

找到了一个方便的解决问题的方法(并且不需要Seaborn):

compmatrix.style.background_gradient(cmap='RdYlGn',axis=1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM