What happened?
I was trying to make this work:
The nice thing about this selection API is that it automatically applies across any compound charts; for example, here we can horizontally concatenate two charts, and since they both have the same selection they both respond appropriately:
from altair.datasets import data as altair_data
interval = alt.selection_interval()
base = alt.Chart(altair_data.cars()).mark_point().encode(
y='Horsepower',
color=alt.condition(interval, 'Cylinders', alt.value('lightgray'))
).properties(
selection=interval
)
base.encode(x='Miles_per_Gallon') | base.encode(x='Acceleration')
Result:
Traceback (most recent call last):
File "/data/code/tdw2/.venv/lib/python3.12/site-packages/altair/vegalite/v6/api.py", line 3804, in _repr_mimebundle_
dct = self.to_dict(context={"pre_transform": False})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/code/tdw2/.venv/lib/python3.12/site-packages/altair/vegalite/v6/api.py", line 2114, in to_dict
vegalite_spec: Any = _top_schema_base(super(TopLevelMixin, copy)).to_dict(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/code/tdw2/.venv/lib/python3.12/site-packages/altair/utils/schemapi.py", line 1226, in to_dict
raise SchemaValidationError(self, err) from None
altair.utils.schemapi.SchemaValidationError: Multiple errors were found.
Error 1: `HConcatChart` has no parameter named 'selection'
Existing parameter names are:
hconcat center description params title
autosize config name resolve transform
background data padding spacing usermeta
bounds datasets
See the help for `HConcatChart` to read the full description of these parameters
The original example was on irises, except I couldn't find iris in altair.datasets so I switched to cars:
interval = alt.selection_interval()
base = alt.Chart(iris).mark_point().encode(
y='petalWidth',
color=alt.condition(interval, 'species', alt.value('lightgray'))
).properties(
selection=interval
)
base.encode(x='petalLength') | base.encode(x='sepalLength')
What would you like to happen instead?
No response
Which version of Altair are you using?
6.1.0
What happened?
I was trying to make this work:
Result:
The original example was on irises, except I couldn't find iris in altair.datasets so I switched to cars:
What would you like to happen instead?
No response
Which version of Altair are you using?
6.1.0