问题
I have the following code to generate a (2,2) gridspec subplots.
gs=GridSpec(2,2)
fig=plt.figure(figsize= (12,6))
ax1=fig.add_subplot(gs[0,0])
ax2=fig.add_subplot(gs[0,1])
ax3=fig.add_subplot(gs[1,:])
ax1.plot(df_wip[['CADUSD=X', 'INRUSD=X', 'PLNUSD=X']], label= ['CAD', 'INR', 'PLN'])
ax1.legend()
ax2.plot(df_wip[['BRLUSD=X', 'ZARUSD=X']])
ax2.set_xticks([])
ax3.plot(df_wip[['CL=F', 'GC=F', '^TNX']])
gs.tight_layout(fig)
See that the legends are not appropriate, and xticks are tight. How to fix them?
Much thanks.
来源:https://stackoverflow.com/questions/61495419/how-to-add-legends-labels-and-fix-tight-layout-in-a-subplot-with-multiple-plot