typeerror in basic example for legend handles in matplotlib

后端 未结 3 1840
独厮守ぢ
独厮守ぢ 2021-01-19 20:23

I have difficulties to understand the legend handling. The more, the basic example from the official matplotlib legend guide

import matplotlib.pyplot as plt         


        
3条回答
  •  北海茫月
    2021-01-19 20:28

    Just remove handles keyword

    Use it like that:

    import matplotlib.pyplot as plt
    line_up, = plt.plot([1,2,3], label='Line 2')
    line_down, = plt.plot([3,2,1], label='Line 1')
    plt.legend([line_up, line_down])
    

提交回复
热议问题