隐藏Altair中的上轴

时间:2018-06-26 14:08:51

标签: python vega vega-lite altair

我想在Altair中隐藏顶轴和右轴(灰色线)。

import pandas as pd
import altair as alt
budget = pd.read_csv("https://github.com/chris1610/pbpython/raw/master/data/mn-budget-detail-2014.csv")
budget_top_10 = budget.sort_values(by='amount',ascending=False)[:10]

alt.Chart(budget_top_10).mark_bar().encode(
    x='detail', 
    y='amount').configure_axis(
    grid=False
)

enter image description here

documentation指向一个.configure_axisTop()命令,但是将其添加到我的代码中并更改其参数似乎没什么区别。

Source of the data

1 个答案:

答案 0 :(得分:3)

很难说,但这不是网格或轴的一部分,而是视图的一部分。您可以使用configure_view(strokeOpacity=0)隐藏它:

import pandas as pd
import altair as alt
budget = pd.read_csv("https://github.com/chris1610/pbpython/raw/master/data/mn-budget-detail-2014.csv")
budget_top_10 = budget.sort_values(by='amount',ascending=False)[:10]

alt.Chart(budget_top_10).mark_bar().encode(
    x='detail', 
    y='amount'
).configure_view(
    strokeOpacity=0
)

enter image description here