I'm getting a TypeError: 'UndefinedType' object is not callable
when running the following Altair code.
import altair as alt
from vega_datasets import data
cars = data.cars()
alt.Chart(cars).mark_point().encode(
x=alt.X('Horsepower').axis(tickMinStep=50),
y=alt.Y('Miles_per_Gallon').title('Miles per Gallon'),
color='Origin',
shape='Origin'
)
Vega-Altair introduced in version 5 a method-based syntax for setting encoding channel options (see docs).
The following line from the OP specification is using a method-based syntax:
x=alt.X('Horsepower').axis(tickMinStep=50)
Where this is written as such using an argument-based syntax:
x=alt.X('Horsepower', axis=alt.Axis(tickMinStep=50))
If you are facing this error you are likely on Vega-Altair version 4.x. You have two options:
For the first, use the documentation of Vega-Altair version 4.
For the latter, currently Vega-Altair version 5 can be installed using the following command:
pip install altair>=5