2015-12-11 202 views
16

看看 this 熱圖在seaborn熱圖文檔中找到。seaborn heatmap y軸逆序

現在y軸從底部9開始,以0結束。 有沒有方法可以解決這個問題,即從底部0開始,最頂端9開始?

回答

20

看起來像ax.invert_yaxis()解決了它。

繼從中得到了圖中的例子:

import numpy as np; np.random.seed(0) 
import seaborn as sns; sns.set() 
uniform_data = np.random.rand(10, 12) 
ax = sns.heatmap(uniform_data) 
ax.invert_yaxis() 

給出: enter image description here

-1

如果您使用的是「十六進制」 jointplot()的熱圖,好像我是,那麼你就可以做到這一點:

import matplotlib.pyplot as plt 
import numpy 
import seaborn 

x = numpy.arange(10) 
y = x**2 

g = seaborn.jointplot(x, y, kind='hex') 
g.fig.axes[0].invert_yaxis() 

plt.show() 

enter image description here