Open
Description
Bug summary
Annotations placed outside of an axes with xycoords='figure fraction'
are not respected by fig.save_fig(bbox_inches='tight')
Code for reproduction
plt.plot([1, 2])
figannot = plt.annotate('figure fraction annotation', (0.2, 0.97), xycoords='figure fraction')
axesannot = plt.annotate('axes fraction annotation', (0.2, 1.05), xycoords='axes fraction')
plt.gcf().savefig('test.svg', bbox_inches='tight')
Actual outcome
This is a screenshot from Inkscape.
Expected outcome
The annotation using figure fraction should get the same treatment as the annotation using axes fraction.
Additional information
The figure fraction annotation returns a Bbox
with get_window_extent
so it beats me.
The effects of this bug are pretty dramatic if leaving a lot of empty space in a figure window (e.g. add_axes((0.1, 0.5, 0.1, 0.4))
).
Operating system
Windows
Matplotlib Version
3.6.3
Matplotlib Backend
Qt5Agg
Python version
Python 3.8.3
Jupyter version
No response
Installation
pip