nik*_*osd 12 python matplotlib legend
我试图通过遵循这里的建议在一个情节图例上有一个数据点,它似乎不起作用:
from pylab import scatter
import pylab
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.gca()
ax.scatter(1,2,c = 'blue', marker = 'x')
ax.scatter(2,3, c= 'red', marker = 'o')
ax.legend(('1','2'), loc = 2, numpoints = 1)
plt.show()
Run Code Online (Sandbox Code Playgroud)

我在做一些完全愚蠢的事吗?一些其他信息:
In [147]: import matplotlib
print matplotlib.__version__
Out [147]: 1.1.1rc
Run Code Online (Sandbox Code Playgroud)
unu*_*tbu 14
对于散点图,请使用scatterpoints参数:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.scatter(1, 2, c='blue', marker='x')
ax.scatter(2, 3, c='red', marker='o')
ax.legend(('1', '2'), loc=2, scatterpoints=1)
plt.show()
Run Code Online (Sandbox Code Playgroud)
