Replies: 3 comments
-
@nicolaskruchten did something along these lines in plotly.express, so he may have some thoughts on the relationship between wide data and Vega-Lite's grammar. |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing this link! Interesting to read how similar issues are approached elsewhere. Melting of the long-form data into wide-form using pandas internally is a possibility (what plx does). Or a macro approach (either python side or typescript-side), where a long-form data structure is detected and reworked into wide-form using a transform_fold or a repeated layer mechanism in vega-lite. I think I favor a macro approach, but also no clear thoughts on this. |
Beta Was this translation helpful? Give feedback.
-
This is an interesting idea! I don't have any strong feelings either way here. I can see how it would be more convenient (and maybe even much more convenient in some cases) to have this functionality. I wonder if it could clash with any new Vega-Lite functionality down the road, although it is hard to imagine what that would look like... |
Beta Was this translation helpful? Give feedback.
-
Dataframes are often categorized as wide-form data:
How to draw this as two line series?
There is a long section in the docs on this topic.
One should use
melt
in pandas, as such:Or apply a
transform_fold
within altair:I think both approaches are rather complicated and in practice I see people doing this:
Honestly, I think this approach is more intuitive than melting or folding.
This could already be improved by using
alt.datum(<my-color>)
to get a legend:Would it be strange to raise if the following could also be supported in the syntax of Altair?
Or is this completely against the grammar? For the tooltip encoding channel we do support a list as input as well.
Edit:
One could even do the following:
Beta Was this translation helpful? Give feedback.
All reactions