Move and resize legends-box in matplotlib

后端 未结 2 697
鱼传尺愫
鱼传尺愫 2021-01-04 04:44

I\'m creating plots using Matplotlib that I save as SVG, export to .pdf + .pdf_tex using Inkscape, and include the .pdf_tex-file in a LaTeX document.

This means tha

2条回答
  •  鱼传尺愫
    2021-01-04 05:27

    You may use the bbox_to_anchor and bbox_transform parameters to help you setting the anchor for your legend:

    ax = plt.gca()
    plt.legend(bbox_to_anchor=(1.1, 1.1), bbox_transform=ax.transAxes)
    

    Note that (1.1, 1.1) are in the axes coordinates in this example. If you wish to use the data coordinates you have to use bbox_transform=ax.transData instead.

提交回复
热议问题