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

如何在Altair分面图表中隐藏行轴的分面索引

隐藏Altair分面图表的行索引标签

你可以通过在Row编码中配置header参数,将标签透明度设为0来隐藏这些无关的分面索引:

import altair as alt

alt.Chart(data).mark_bar().encode(
    x=alt.X('Start', title=''),
    x2='End',
    color=alt.Color('Product', scale=alt.Scale(scheme='dark2'))
).properties(
    width=800,
    height=50
).facet(
    row=alt.Row('Row', title='', header=alt.Header(labelOpacity=0)),  # 配置header隐藏标签
).resolve_scale(
    x='independent',
)

如果需要彻底移除行标题区域的空白占位,还可以补充设置标题透明度和内边距:

row=alt.Row('Row', title='', header=alt.Header(
    labelOpacity=0,
    titleOpacity=0,
    labelPadding=0
))

这样就能完全隐藏分面行的索引标签及相关空白区域,只保留核心图表内容。

内容的提问来源于stack exchange,提问作者Christoph Burschka

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 06:02:34