使用 altair 包时,我注意到创建图表时还会生成图例。以下代码:import altair as altfrom vega_datasets import dataalt.renderers.enable('notebook')cars = data.cars()alt.Chart(cars).mark_circle().encode(x='Horsepower', y='Miles_per_Gallon', color='Origin', tooltip=['Name', 'Origin', 'Horsepower', 'Miles_per_Gallon']).interactive()产生这个图:我的问题:有没有办法在图形输出中抑制这个图例?
1 回答

Smart猫小萌
TA贡献1911条经验 获得超7个赞
该altair模块的文档中有一个示例。你可以在这里找到它。
在这里,他们将 Legend 设置为None,这将删除图例。
这是他们的示例代码:
import altair as alt
from vega_datasets import data
iris = data.iris()
alt.Chart(iris).mark_point().encode(
x='petalWidth',
y='petalLength',
color=alt.Color('species', legend=None),
)
添加回答
举报
0/150
提交
取消