matplotlib legend: Including markers and lines from two different graphs in one line

后端 未结 3 1173
难免孤独
难免孤独 2020-12-20 20:56

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 fak

3条回答
  •  無奈伤痛
    2020-12-20 21:37

    You just need to use legend a bit more directly. See Matplotlib - How to make the marker face color transparent without making the line transparent and user guide.

    ax.legend([(p1, p3), (p2, p4)], ['set 1', 'set 2'])
    plt.draw()
    

提交回复
热议问题