2016-10-27 4 views
0

그림과 같이 내 질문을 묘사합니다. 인해 매핑 설정에MatPlotLib을 포함하는 두 개의 서브 플롯에 대한 플롯 테두리 프레임 설정 .Basemap 내용

enter image description here

fig = plt.figure(figsize = (10,4)) 
ax1 = plt.subplot(121) 
map =Basemap(llcrnrlon=x_map1,llcrnrlat=y_map1,urcrnrlon=x_map2,urcrnrlat=y_map2) 
map.readshapefile('shapefile','shapefile',zorder =2,linewidth = 0) 
for info, shape in zip(map.shapefile, map.shapefile): 
    x, y = zip(*shape) 
    map.plot(x, y, marker=None,color='k',linewidth = 0.5) 
plt.title("a") 
ax2 = plt.subplot(122) 
y_pos = [0.5,1,] 
performance = [484.0,1080.0] 
bars = plt.bar(y_pos, performance, align='center') 
plt.title("b") 
부가 적 줄거리 (b)와 일치하지 않는다. 따라서, subplot (a)와 subplot (b)에는 독특한 보드 프레임이 있습니다. 내 의견으로는, 정렬되지 않은 경계는 독자에게 유쾌하지 않습니다.

전체 그림으로 조화를 이루기 위해 subplot (b)의 테두리 크기를 조정할 수있는 방법이 있습니까? 부가 적 줄거리의 (a) matplotlib.basemap 요소를 포함 할 필요가 있음을

enter image description here

주의 사항 :

이 내 대상입니다.

답변

1

현재 왼쪽의 서브 플로트는 'equal'의 가로 세로 비율을 가지며 다른 하나는 자동입니다. 따라서 오른쪽에있는 서브 플로트의 종횡비를 수동으로 설정해야합니다.

def get_aspect(ax): 
    xlim = ax.get_xlim() 
    ylim = ax.get_ylim() 
    aspect_ratio = abs((ylim[0]-ylim[1])/(xlim[0]-xlim[1])) 

    return aspect_ratio 

ax2.set_aspect(get_aspect(ax1)/get_aspect(ax2))