问题描述
我想构建 2 个“块”,将颜色框和文本与另一个包含与颜色框和相关文本相对应的数值混合在一起。
目前,我有这个使用 getdist library 的脚本:
g = plots.get_subplot_plotter()
g.add_legend(['Opt. Flat. No Gamma. - WL - FoM = 47.05','Opt. Flat. No Gamma. - GCsp - FoM = 52.12','Opt. Flat. No Gamma. - GCph - FoM = 61.88','Opt. Flat. No Gamma. - GCsp + GCph+WL+XC - FoM = 1209.80','Opt. Flat. No Gamma. - Common bias - FoM = 1567.18'],legend_loc='upper right',bBox_to_anchor=(bottom_right_plot,top_left_plot),bBox_transform=plt.gcf().transfigure,# this is the x and y coords we extracted above
borderaxespad = 0,# this means there is no padding around the legend
)
我在右上角得到以下图例,仅形成一个块:
现在我希望能够在图例的同一框架内有 2 个块:从左侧的第一侧,我想要颜色框和文本,从另一侧,我想在右侧获得类似 "FoM =" 47.05
的数值,然后形成由所选空间分隔的 2 个块。
如果我使用 2 次 add_legend
函数而不是上面的函数(只调用一次),
# First legend
g.add_legend(['Opt. Flat. No Gamma. - WL :','Opt. Flat. No Gamma. - GCsp :','Opt. Flat. No Gamma. - GCph :','Opt. Flat. No Gamma. - GCsp +(GCph+WL+XC) :','Opt. Flat. No Gamma. - Common bias :'],# this means there is no padding around the legend
)
# Second legend
g.add_legend([
' FoM = 47.05',' FoM = 52.12','FoM = 61.88','FoM = 1209.80','FoM = 1567.18'],# this means there is no padding around the legend
)
我明白了:
但是正如你所看到的,所有的文本部分都没有显示出来,只有颜色框和数值。
如何制作由选定空间分隔并在单个框架内的 2 个块,左侧的一个块包含颜色框和文本,第二个块位于右侧并包含所有“FoM”的一部分= ...." 与第一个块对齐?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)