비교적 간단한 질문을 드리겠습니다. 저는 두 개의 그래프 차트를 가지고 있습니다. 그 중 하나에는 범주가 더 많으므로 각 막대의 너비가 더 작습니다. 샘플 코드/아래 그래프 (단순, 표준 플로팅)를 참조하십시오 :Matplotlib - 가로 막 대형 차트 값을 찾으십시오.
fig, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
ax1.set_title("Sample Graph", size='16')
ax1.bar(df1.index, df1.c_destination, color='purple', alpha =1)
ax1.set_axisbelow(True)
ax1.set_xticks(df1.index)
ax1.set_xticklabels(df1['index'], rotation=45, ha='right', size='14')
ax1.patch.set_facecolor(color='gray')
ax1.patch.set_alpha(0.5)
ax2.set_title("Sample Graph Other", size='16')
ax2.bar(df2.index, df2.destination, color='purple', alpha =1)
ax2.set_axisbelow(True)
ax2.set_xticks(df2.index)
ax2.set_xticklabels(df2['index'], rotation=45, ha='right', size='14')
ax2.patch.set_facecolor(color='gray')
ax2.patch.set_alpha(0.5)
를 왼쪽 그래프는 12 바가 있습니다 오른쪽 그래프는 어떻게 적은 막대 그래프를 보장 할 수 8 개 바있는 경우가 같은 바 너비? 각 너비를 정의 할 수 있지만 ax2가 ax1에서이 값에 액세스 할 수 있는지 궁금하네요? 도와 줘서 고마워.
'bar (x, y, width = 30)'너는 단지'width' 인자를 사용하여 이것을 할 수 없습니까? 가치가있는 시도 – mtkilic
내가 말할 수 있지만 나는 ax1과 ax2를 개별적으로 정의 할 필요가있다. 나는 ax1에서 자동으로 생성 된 너비를 이용하고 ax2로 넘겨 주려고합니다. –