【发布时间】:2015-07-21 13:04:51
【问题描述】:
我遇到了与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()
但是,我的两个(金星和火星)标记在图例中重叠。我尝试使用句柄长度,但这似乎没有帮助。任何建议或 cmets 都会有所帮助。
【问题讨论】:
标签: matplotlib label legend scatter-plot markers