gpt4 book ai didi

python - 如何移除如图所示的 Altair yaxis?

转载 作者:行者123 更新时间:2023-12-04 16:40:39 28 4
gpt4 key购买 nike

enter image description here

如何去除蓝色部分?

import altair as alt
from vega_datasets import data

iris = data.iris()

alt.Chart(iris).mark_point().encode(
x='petalWidth',
y='petalLength',
color='species'
).configure_axis(
grid=False
).configure_view(
strokeWidth=0
)

我花了一整个下午才找到删除它的正确语法,参数太多,我完全糊涂了。谢谢。

最佳答案

您可以通过设置 axis=None 隐藏轴在相关的编码中:

import altair as alt
from vega_datasets import data

iris = data.iris()

alt.Chart(iris).mark_point().encode(
x='petalWidth',
y=alt.Y('petalLength', axis=None),
color='species'
).configure_axis(
grid=False
).configure_view(
strokeWidth=0
)

enter image description here

如果只想隐藏刻度线和域线,可以设置 ticksdomain轴属性为 False :
alt.Chart(iris).mark_point().encode(
x='petalWidth',
y=alt.Y('petalLength', axis=alt.Axis(ticks=False, domain=False)),
color='species'
).configure_axis(
grid=False
).configure_view(
strokeWidth=0
)

enter image description here

关于python - 如何移除如图所示的 Altair yaxis?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61697838/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com