altair icon indicating copy to clipboard operation
altair copied to clipboard

ENH: streamline repeat API

Open jakevdp opened this issue 6 years ago • 1 comments

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]
)

visualization 17

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...

jakevdp avatar May 08 '18 18:05 jakevdp

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'

iliatimofeev avatar Jun 10 '18 17:06 iliatimofeev