如何隐藏轴线但在 Altair 的图表中显示刻度线,同时积极使用 "axis" 参数?

How to hide axis lines but show ticks in a chart in Altair, while actively using "axis" parameter?

我知道使用 axis=None 隐藏轴线。但是,当您主动使用 axis 修改图形时,是否可以只保留刻度线,但隐藏 X 轴和 Y 轴的轴线?

例如,这是我希望它发生的地方的图表 -

import pandas as pd
import altair as alt

df = pd.DataFrame({'a': [1,2,3,4], 'b':[2000,4000,6000,8000]})

alt.Chart(df).mark_trail().encode(
    x=alt.X('a:Q', axis=alt.Axis(titleFontSize=12, title='Time →', labelColor='#999999', titleColor='#999999', titleAlign='right', titleAnchor='end', titleY=-30)),
    y=alt.Y('b:Q', axis=alt.Axis(format="$s", tickCount=3, titleFontSize=12, title='Cost →', labelColor='#999999', titleColor='#999999', titleAnchor='end')),
    size=alt.Size('b:Q', legend=None)
).configure_view(strokeWidth=0).configure_axis(grid=False)

输出应该类似于此 SO .
中的刻度 注意:post中的情节与此处提供的演示无关。仅供理解之用。

Vega-Lite 将轴线称为 。您可以通过将 domain=False 传递给轴配置来隐藏它:

import pandas as pd
import altair as alt

df = pd.DataFrame({'a': [1,2,3,4], 'b':[2000,4000,6000,8000]})

alt.Chart(df).mark_trail().encode(
    x=alt.X('a:Q', axis=alt.Axis(titleFontSize=12, title='Time →', labelColor='#999999', titleColor='#999999', titleAlign='right', titleAnchor='end', titleY=-30)),
    y=alt.Y('b:Q', axis=alt.Axis(format="$s", tickCount=3, titleFontSize=12, title='Cost →', labelColor='#999999', titleColor='#999999', titleAnchor='end')),
    size=alt.Size('b:Q', legend=None)
).configure_view(strokeWidth=0).configure_axis(grid=False, domain=False)