简体   繁体   中英

Hide top axis in Altair

I would like to hide the top and right axis (gray lines) in 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
)

在此处输入图片说明

The documentation points to a .configure_axisTop() command but adding it to my code and changing its arguments seems to make no difference.

Source of the data .

It's hard to tell, but that is not part of the grid or axis, but part of the view. You can hide it using 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
)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM