xarray support
Author: bocklundCreated May 23, 2018Updated May 30, 2026
Labelsenhancementvega: vega-litevega: vega
Is it possible or planned that xarray be supported natively?
You can't pass in Datasets or DataArrays directly to altair. Using .to_dataframe() doesn't quite work either because xarray creates a hierarchical index, which are not supported.
However, you can reset the index to flatten out the DataFrame.
my_xr_dataset = calc_res.isel(component=1)
df = my_xr_dataset.to_dataframe()
df.reset_index(inplace=True)
alt.Chart(df).mark_circle().encode(
x='X',
y='GM',
color='Phase',
).interactive()You still have to slice up the Dataset yourself (the point limit can be somewhat limiting unless you slice up the Dataset).
Thoughts?
Tracking
Source: vega/altair