Matplotlib Legend Guide basic examples

后端 未结 2 1608
粉色の甜心
粉色の甜心 2020-12-17 03:37

I am trying to understand how to use the legend() better, specifically how to use proxy artists. I find the Legend guide to be severely lacking. This post is somewhat simila

2条回答
  •  -上瘾入骨i
    2020-12-17 04:14

    The Legend Guide was rewritten to be compatible with matplotlib version 1.4.0 or newer. Your version of matplotlib (1.2.1) is over two years old. Don't be surprised if everything shown in the docs does not work with such an old version.

    If you upgrade your version, then using

    plt.legend(handles=[red_patch,blue_line])
    

    (as is shown in the Legend Guide) instead of

    plt.legend([red_patch,blue_line])
    

    yields

    enter image description here

提交回复
热议问题