从给定数据集生成热图

时间:2017-08-04 09:08:19

标签: python matplotlib

在下面的热图中,我想从0到25开始y值。现在它是相反的方向。

import matplotlib.pyplot as plt
import numpy as np
import matplotlib
import matplotlib
matplotlib.rc('text', usetex=True)
matplotlib.rcParams['text.latex.preamble']=[r"\usepackage{amsmath}"]
a=[]
for i in range(25):
    b=[]
    for j in range(25):
        b.append(i*j)
    a.append(b)    
fig = plt.figure(figsize=(8,5.00))
plt.imshow(a,  interpolation='nearest')
plt.colorbar()
ax = fig.add_subplot(1,1,1)
major_ticks = np.arange(0, 24, 2)                                              
minor_ticks = np.arange(0, 24, 1)                                               
ax.set_xticks(major_ticks)                                                       
ax.set_xticks(minor_ticks, minor=True)
plt.xlabel(r'$\pmb{u} \  \longrightarrow$' )
plt.ylabel(r'$\pmb{v} \  \longrightarrow$')
plt.show()
fig.savefig('abc.eps', bbox_inches = 'tight',
    pad_inches = 0.2)

1 个答案:

答案 0 :(得分:0)

需要包含origin =' lower'