【发布时间】:2013-10-15 15:51:47
【问题描述】:
我正在尝试使用这个 sn-p 将图例添加到我的情节中:
import matplotlib.pylab as plt
fig = plt.figure()
axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) # left, bottom, width, height (range 0 to 1)
axes.set_xlabel('x (m)')
axes.set_ylabel('y (m)')
for i, representative in enumerate(representatives):
axes.plot([e[0] for e in representative], [e[1] for e in representative], color='b', label='Representatives')
axes.scatter([e[0] for e in intersections], [e[1] for e in intersections], color='r', label='Intersections')
axes.legend()
我结束了这个情节
显然,这些项目在图中重复。我该如何纠正这个错误?
【问题讨论】:
-
这不是一个错误,它添加了许多重复的条目,因为标签是相同的。如果必须更改 for 循环内的标签...
-
这是您问题的一个很好的答案:stackoverflow.com/questions/13588920/…
标签: python matplotlib