【问题标题】:Text on the left side of the symbol in matplotlib legend [duplicate]matplotlib图例中符号左侧的文本[重复]
【发布时间】:2019-03-03 13:17:45
【问题描述】:

是否有任何内置函数/方法或简洁的方式将文本放在图例中标记/符号的左侧?

【问题讨论】:

    标签: python matplotlib legend


    【解决方案1】:

    这可以通过将matplotlib.pyplot.legend的参数markerfirst设置为False来完成。

    markerfist : 布尔 如果为 True,则图例标记放置在图例标签的左侧。如果为 False,则图例标记放置在图例标签的右侧。默认为真。

    类似的东西:

    t = np.arange(0.0, 2.0, 0.01)
    s = 1 + np.sin(2 * np.pi * t)
    
    fig, ax = plt.subplots()
    ax.plot(t, s, label='sine')
    ax.legend(markerfirst=False)
    
    plt.show()
    

    我希望这就是你要找的:)

    【讨论】:

    • 这正是我想要的。谢谢
    猜你喜欢
    • 2020-12-20
    • 2021-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-05
    • 1970-01-01
    • 2013-07-02
    • 2016-06-29
    相关资源
    最近更新 更多