Hopefully a relatively straightforward question here- I have two barcharts I'm graphing. One of them has more categories, thus the width of each bar is smaller. See sample code/graph below (simple, standard plotting):
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)
If the left graph has 12 bars and the right graph has 8 bars, how can I ensure the graph with fewer bars has the same bar width? I know I could define width in each, but I'm wondering if ax2 can access this value from ax1? Thank you for your help.
