Text or legend cut from matplotlib figure on savefig()

后端 未结 2 1848
礼貌的吻别
礼貌的吻别 2020-12-31 07:53

Say I want to plot a very simple figure with 2-subplot laid out horizontally, and I want to add some text on the right of the second subplot. I am working in Jupyter Noteboo

2条回答
  •  伪装坚强ぢ
    2020-12-31 08:41

    Adding bbox_inches="tight" to the savefig **kwargs will do it:

    plt.savefig(r'C:\mypy\test_graph.png', ext='png', bbox_inches="tight")  
    

    Saved file:

提交回复
热议问题