altair
altair copied to clipboard
ENH: streamline repeat API
Currently the repeat API is a bit clunky. For example:
import altair as alt
from vega_datasets import data
iris = data.iris()
fields = ['petalLength', 'petalWidth', 'sepalLength', 'sepalWidth']
alt.Chart(iris).mark_point().encode(
alt.X(alt.repeat("column"), type='quantitative'),
alt.Y(alt.repeat("row"), type='quantitative'),
color='species'
).repeat(
row=fields,
column=fields[::-1]
)
This is not as streamlined as I'd like... for example, type inference and type shortcuts (e.g. petalLength:Q
) are not supported, and the indirection of using alt.repeat("row")
is a bit much.
That said, I'm not certain how we could best simplify this API without drifting too far from the underlying vega-lite schema structure...
import altair as alt
from vega_datasets import data
iris = data.iris()
alt.Chart(iris).mark_point().encode(
x='$(column):Q',
y='$(row):Q',
color='species'
).repeat('both')
JQuery style? or just x='$column:Q'