我遇到了“类似”的问题Matplotlib,一个标签具有多个不同标记的图例 https://stackoverflow.com/questions/9262307/matplotlib-legend-with-multiple-different-markers-with-one-label。由于这个问题,我能够实现以下目标结合两个 Pyplot 补丁作为图例 https://stackoverflow.com/questions/28732845/combine-two-pyplot-patches-for-legend/30090153#30090153.
fig = pylab.figure()
figlegend = pylab.figure(figsize=(3,2))
ax = fig.add_subplot(111)
point1 = ax.scatter(range(3), range(1,4), 250, marker=ur'$\u2640$', label = 'S', edgecolor = 'green')
point2 = ax.scatter(range(3), range(2,5), 250, marker=ur'$\u2640$', label = 'I', edgecolor = 'red')
point3 = ax.scatter(range(1,4), range(3), 250, marker=ur'$\u2642$', label = 'S', edgecolor = 'green')
point4 = ax.scatter(range(2,5), range(3), 250, marker=ur'$\u2642$', label = 'I', edgecolor = 'red')
figlegend.legend(((point1, point3), (point2, point4)), ('S','I'), 'center', scatterpoints = 1, handlelength = 1)
figlegend.show()
pylab.show()
然而,我的两个(金星和火星)标记在图例中重叠。我尝试玩手柄长度,但这似乎没有帮助。任何建议或意见都会有帮助。