3
votes

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
)

enter image description here

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.

1

1 Answers

4
votes

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
)

enter image description here