matplotlib: put legend symbols on the right of the labels

It's a simple thing but I've searched for quite a while without success: I want to customise a figure legend by reversing the horizontal order of the symbols and labels.

In Gnuplot, this is simply achieved by set key reverse . Example: change x data1 to data1 x . In matplotlib, there seems to be no user-friendly solution. Thus, I thought about changing a kind of handle anchor or just shifting the handle's position, but couldn't find any point to start with.


The requested feature is already there, as the keyword markerfirst of the legend command.

    plt.plot([1,2],[3,4], label='labeltext')
    plt.legend(markerfirst=False)
    plt.show()

If you want to make it your default behaviour, you can change the value of legend.markerfirst in rcParams , see customizing matplotlib.

链接地址: http://www.djcxy.com/p/21916.html

上一篇: 用JavaScript / jQuery重定向发送POST数据?

下一篇: matplotlib:在标签的右侧放置图例符号