[Python] Matplotlib Legends not working

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    Ever since upgrading matplotlib I get the following error whenever trying to create a legend:

    /usr/lib/pymodules/python2.7/matplotlib/legend.py:610: UserWarning: Legend does not support [<matplotlib.lines.Line2D object at 0x3a30810>]
    Use proxy artist instead.

    http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

    warnings.warn("Legend does not support %s\nUse proxy artist instead.\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle),))
    /usr/lib/pymodules/python2.7/matplotlib/legend.py:610: UserWarning: Legend does not support [<matplotlib.lines.Line2D object at 0x3a30990>]
    Use proxy artist instead.

    http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

    warnings.warn("Legend does not support %s\nUse proxy artist instead.\n\nhttp://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist\n" % (str(orig_handle),))


    This even occurs with a trivial script like this:

    import matplotlib.pyplot as plt

    a = [1,2,3]
    b = [4,5,6]
    c = [7,8,9]

    plot1 = plt.plot(a,b)
    plot2 = plt.plot(a,c)

    plt.legend([plot1,plot2],["plot 1", "plot 2"])
    plt.show()


    I've found the link that the error points me towards pretty useless in diagnosing the source of the error.

    Continue reading...

Compartilhe esta Página