pythonmatplotlibsubplotsavefig

Why does the upper table overlap the lower figure-lines?


Question is a figure & table together from different axes.

On the one hand, its fine in figure window shows below, after constrained_layout=True is added:

enter image description here

On the other hand, the lower-lines and upper-table overlapped after save it to picture. plt.savefit("path+fig.png", bbox_index='tight)

enter image description here


Solution

  • I've learned how to avoid the problem that lines and tables overlapped each other.(yet not fully understand)

    plt.savefig('path+name.jpg', bbox_inches='tight')
    plt.tight_layout()
    

    instead of

    plt.tight_layout()
    plt.savefig('path+name.jpg', bbox_inches='tight')
    


    • plt.tight_layout() can only zoom the lines excluding tables;
    • plt.rcParams['figure.autolayout']=True can zoom both of lines and tables in the figure window.