在 matplotlib 图例中的两行上绘制一个大括号

Joh*_*ann 4 python matplotlib legend

我想为图例的两行画一个大括号,如下所示:

大括号表示两个图例条目的共享属性

我可以使用 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() 
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

Joh*_*ann 8

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

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