python - 在 matplotlib 图例中的两条线上画一个大括号

标签 python matplotlib legend

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

curly bracket indicates a shared property for two legend entries

我可以用 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() 

如有任何帮助,我们将不胜感激。

最佳答案

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

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

关于python - 在 matplotlib 图例中的两条线上画一个大括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48770052/

相关文章:

matplotlib - Pyplot 自动排序 y 值

python - 我如何用 flask 扭曲运行?

python - 如何将一片数据帧转换为新的数据帧

python - 如何使用 dask 应用平滑过滤器

python - 通过 python 将空白单元格保持为空白而不是无

python - Matplotlib 未知属性 "headwidth"和 "head_width"

matplotlib - pyplot直方图箱如何解释?

gnuplot - 如何在 gnuplot 图例中获取波形符或近似符号?

python - 如何为子图绘制动画图例?

css - 如何防止 fieldset 的边框穿过 form 标签包围的图例元素?