我與Matplotlib, legend with multiple different markers with one label有'相似'問題。由於這個問題Combine two Pyplot patches for legend,我能夠實現以下目標。具有相同標籤的不同散點圖標記
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()
但是,我的兩個(金星和火星)標記在圖例中重疊。我嘗試玩handlelength,但這似乎沒有幫助。任何建議或意見都會有所幫助。
您還可以調整列間距以將它們靠得更近。 – Blink