Closed
Description
2.0b4 and master
from matplotlib import pyplot as plt
import numpy as np
plt.rcdefaults()
np.random.seed(1)
plt.plot(*np.random.rand(2, 300), ".", label="some long legend")
plt.plot(*np.random.rand(2, 300), ".", label="other long legend")
plt.legend()
plt.savefig("/tmp/foo.png")
plt.show()
The displayed window puts the legend at the center top of the figure, but the saved image puts the legend at the bottom left.
By changing the seed one can get cases where the two legends do match each other. In that case, careful inspection of the images show that the legends have slightly different sizes, which make them overlap with different number of points depending on the corner in which they are tentatively placed by the autolocator -- this is what leads to them moving upon saving.