2017-05-15 5 views
0

heatmap of plotly과 비슷한 matplotlib을 사용하여 히트 맵을 플롯하려고했습니다. matshow 그림의 크기에 따른 출력을 얻을 수있는 것은 매우 작습니다.python : matplotlib의 ax.matshow 크기 변경

import pandas as pd 
import numpy as np 
import matplotlib.pyplot as plt 

z = [] 

for _ in range(7): 
    new_row = [] 
    for __ in range(180): 
     new_row.append(np.random.poisson()) 
    z.append(list(new_row)) 

df1 = pd.DataFrame(np.array(z), columns=range(len(z[0]))) 

fig = plt.figure(figsize=(20,10)) 

ax = fig.add_subplot(111) 

cax = ax.matshow(df1, interpolation='nearest', cmap='coolwarm') 
fig.colorbar(cax) 

ax.set_xticklabels([''] + list(df1.columns)) 
ax.set_yticklabels([''] + list(df1.index)) 

plt.show() 

이 친절하게 도와 : enter image description here

다음 내 코드입니다 : 다음은 아래 그림을 얻을 수있는 그림 enter image description here

입니다.

답변

2

당신은 imshow 또는 matshow에 동일한 측면의 제한을 제거

ax.matshow(... , aspect="auto") 

를 사용할 수 있습니다.

+0

고맙습니다. 그것은 효과가 있었다. – Jeril

관련 문제