【问题标题】:Draw a curly bracket over two lines in a matplotlib legend在 matplotlib 图例中的两行上画一个大括号
【发布时间】:2018-02-13 15:20:03
【问题描述】:

我想为图例的两行画一个大括号,像这样:

我可以使用 pyplot 创建除大括号之外的所有内容

plt.plot([],[],"ro",label="a")
plt.plot([],[],"bo",label="b")
plt.legend(frameon=False,loc="upper left")
plt.annotate("some property",
            xy=(0.31, 0.7), xycoords='figure fraction',
            xytext=(0.31,  0.79), textcoords='figure fraction',
            arrowprops=dict(arrowstyle="-",lw=0
                       )
            )
 plt.plot() 

任何帮助将不胜感激。

【问题讨论】:

  • 我想知道您是如何设法创建一个显示"some property" 的注释,但未能创建一个显示"}" 的注释。
  • 我也是。这就是我来这里的原因。就像我上面说的:任何帮助将不胜感激。编辑:好的,我现在明白了...谢谢:)

标签: python matplotlib legend


【解决方案1】:

感谢 ImportanceOfBeingErnest 的评论,我意识到简单地添加另一个注释的明显解决方案:

plt.annotate(r"$\}$",fontsize=24,
            xy=(0.27, 0.77), xycoords='figure fraction'
            )

【讨论】:

    猜你喜欢
    • 2015-06-09
    • 2013-07-06
    • 2018-09-22
    • 1970-01-01
    • 2017-08-28
    • 2020-11-17
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    相关资源
    最近更新 更多