【发布时间】:2020-09-11 18:04:52
【问题描述】:
我尝试手动设置由 Getdist tool 制作的主图的主要图例的位置。
下图表示来自具有联合分布的协方差矩阵的 1/2 sigma 置信水平。由 Getdist tool制作。
Getdist tool 工具允许指定图例的位置:我尝试使用legend_loc = 'upper right',但如您所见,图顶部有重叠。我想向右移动图例以避免这种重叠:有可能吗?如果是,怎么做?
生成此图的主要程序是:
g.triangle_plot([matrix1, matrix2],
names,
filled = True,
legend_labels = ['Opt. Flat. No Gamma. - optimistic case - cross - standard situation - Criterion taking into accound a = 200', 'Pess. Flat. No Gamma. - pessimistic case - cross - standard situation - Criterion taking into account a = 300' ],
legend_loc = 'upper right',
contour_colors = ['darkblue','red'],
line_args = [{'lw':2, 'color':'darkblue'},
{'lw':2, 'color':'red'}]
)
更新 1
我无法通过以下方式在图例的左下角应用移位:
g.triangle_plot([matrix1, matrix2],
names,
filled = True,
legend_labels = ['Opt. Flat. No Gamma. - optimistic case - cross - standard situation - Criterion taking into accound a = 200', 'Pess. Flat. No Gamma. - pessimistic case - cross - standard situation - Criterion taking into account a = 300' ],
legend_loc = 'center right',
contour_colors = ['darkblue','red'],
line_args = [{'lw':2, 'color':'darkblue'},
{'lw':2, 'color':'red'}],
bbox_to_anchor = [0.1, 0.5]
)
如您所见,我尝试将图例放在顶部和中间的 0.1 处。
但不幸的是,这并没有改变任何东西,我用这些参数得到了以下情节:
您可以说,使用这些参数,简单地移到顶部就足够了,但我暂时不知道如何执行此操作。
我还尝试从g.triangle_plot 中删除loc 和bbox_to_anchor 并尝试直接执行:
g.fig.legend(loc='center right', bbox_to_anchor=[0.1, 0.1])
但最终图中未应用相同的偏移量问题。
【问题讨论】:
-
有用的评论:在英语中,一个说“我希望问题很清楚”,而不是“我希望问题很清楚”。但是,在 Stack Overflow 上,我们热衷于解决闲聊问题 - 说您希望某事清楚并不会帮助其清晰,因此希望您不要发表这些多余的言论。
标签: python numpy matplotlib legend