I am adding some text to my plot (always in the left top corner), and when I add legend with loc='best' it seems to ignore the text.
Code to reproduce the problem:
import matplotlib.pyplot as plt
x = [1, 2]
plt.plot(x, x, label='plot name')
plt.gca().text(0.05, 0.95, 'some text', transform=plt.gca().transAxes, verticalalignment='top')
plt.legend(loc='best')
plt.show()
The result I get:
My text is always in the same place, so if I can exclude 'upper left' from best options it will work as well. But curious why the algorithm of loc ignores it.
Thanks
