简体   繁体   中英

create heatmap for each row in pandas dataframe

Below is a df called "compmatrix":

             -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. Can't seem to find the solution I'm looking for in the documentation.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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