[英]How to hide axis lines but show ticks in a chart in Altair, while actively using “axis” parameter?
I am aware of using axis=None
to hide axis lines.我知道使用axis=None
来隐藏轴线。 But when you have actively used axis
to modify the graph, is it possible to keep just the ticks, but hide the axis lines for both X and Y axis?但是当您积极使用axis
来修改图形时,是否可以只保留刻度,但隐藏 X 和 Y 轴的轴线?
For example, here is a graph I have where I'd like it to happen -例如,这是我希望它发生的图表 -
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)
The output should look like the ticks in this SO post . output 应该看起来像这个 SO post中的刻度。
Note: The plot in that post has nothing to do with the demo provided here.注意:该帖子中的 plot 与此处提供的演示无关。 its just for understanding purposes.它只是为了理解目的。
Vega-Lite calls the axis line the domain . Vega-Lite 将轴线称为域。 You can hide it by passing domain=False
to the axis configuration:您可以通过将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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.