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

如何移除Altair图表图例旁的方块及内部圆点?

移除Altair图例旁的方块及内部圆点

要移除图例旁的方块和内部圆点,你可以在alt.Color的配置中,通过legend参数将图例的标记符号设为无,具体做法是设置symbolType='none'。

修改后的代码如下:

import pandas as pd
import altair as alt

df = pd.DataFrame({'x':['a','b','c'],
                    'y':[1,2,3]})

legend = alt.Chart(df).mark_point().encode(
    color=alt.Color('x:N', legend=alt.Legend(symbolType='none'))
)
legend

如果需要进一步调整图例样式,还可以通过legend的其他参数(比如labelFontSize、title等)自定义,核心是通过symbolType='none'隐藏图例前的标记元素。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 09:15:34