You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power BI中Python热力图:如何让Pandas/Matplotlib图例符号居标签上方

问题:调整Power BI中Python视觉对象图例的符号与标签对齐方式

我正在Power BI中使用Python视觉对象制作自定义热力图,需要调整图例内元素的对齐方式,让图例符号位于标签上方,以此匹配成品样式。之前尝试用set_x和set_y方法将文本移至符号下方,虽然能移动文本,但无法让元素与整个图例框良好对齐,相关代码如下:

osLegend = fig.legend( labels = ma, loc="center", bbox_to_anchor = (.8, .3),
        ncol = 3, labelspacing = 1, title = "Opportunity Size", markerscale = .5,
        markerfirst = False, columnspacing = .8)

for text in osLegend.get_texts():
    text.set_x(75)
    text.set_y(-30)

当前效果如图:
当前图例效果

内容的提问来源于stack exchange,提问作者Krishan Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 06:22:36