matplotlib legend: Including markers and lines from two different graphs in one line
问题 I've been doing some linear regression and want to plot the markers (original data) and the lines (regression) on the same line in the legend. For simplicity, here's a fake regression: from pylab import * ax = subplot(1,1,1) p1, = ax.plot([1,2,3,4,5,6],'r-', label="line 1") p2, = ax.plot([6,5,4,3,2,1],'b-', label="line 2") p3, = ax.plot([1.2,1.8,3.1,4.1,4.8,5.9],'ro', label="dots 1") p4, = ax.plot([6.1,5.1,3.8,3.1,1.9,0.9],'bo', label="dots 2") ax.legend(loc='center right',numpoints=1) show()