1
votes

I am using matplotlib 1.10.1. The following code plots a scatter plot and adds a legend in the "best" location.

import matplotlib.pyplot as plt
import numpy as np
x=np.linspace(1.1,2.8)
for i in range(0, 5):
    plt.scatter(x, x, label='Scatter%d' % i)
#plt.plot(x, x)
#plt.legend(loc='upper left')
plt.legend(loc='best')
plt.show()

However, the legend appears in the upper right corner covering some points. I was expecting it to appear in the upper left corner where there is no data. Plotting a line instead of a scatter plot seems to produce the expected behaviour.

Is there a way to fix the "best" legend location for scatter plots?

Thanks

1

1 Answers

0
votes

I think you have encountered this issue and the patch suggested in the thread there has not made it into the master branch.

So I think your only option is to apply it manually.