Description
Bug report
Bug summary
If I add a draggable legend to a plot, then move it to a desired position by dragging it, then save the plot to a PDF by using savefig, the legend position on the PDF is not the same as the legend position I dragged it to on the screen.
Code for reproduction
from matplotlib import pyplot as plt
import numpy as np
x = np.linspace(-2.*np.pi, 2.*np.pi, 1000)
y = np.sin(x)
plt.plot(x, y, '-', lw=2, label='Sine curve')
leg = plt.legend(loc='best', fontsize=20)
leg.draggable(True)
plt.show()
After running this code, drag the legend manually to the lower left of the plot, then issue the command
plt.savefig('sine_curve.pdf')
Actual outcome
On the screen, after dragging the legend the plot looks like plot_on_screen.png. However, the saved PDF looks like sine_curve.pdf. Notice how the legend is obviously at a different location than where I placed it by dragging.
sine_curve.pdf
Expected outcome
The legend should stay in the same place in the PDF as on the screen. This used to be the case with matplotlib 1.5.3.
Matplotlib version
- Operating system: Linux x64
- Matplotlib version: 2.1.2
- Matplotlib backend: Qt4Agg
- Python version: 2.7.6
- Jupyter version (if applicable): N/A
- Other libraries:
I installed matplotlib from source.