microsoft / datamations

https://microsoft.github.io/datamations/
Other
67 stars 14 forks source link

Try to render two key frames with vega(lite?) and animate between them #12

Closed jhofman closed 3 years ago

jhofman commented 3 years ago

It looks like Vega (or Vega-lite) might be a good "exchange format" for passing plot specifications between a base language (like R) and a rendering language (like d3).

For now, let's try to just make plots of two key frames from the salary datamation using it and see if we can link them with a transition. Specifically:

Frame 1: Scatter plot of x = degree, y = salary, color = degree Frame 2: Plot of average salary by degree, x = degree, y = mean_salary, color = degree

jhofman commented 3 years ago

If this is successful in "vanilla" Vega, then let's see if we can generate the same from R using one of these:

giorgi-ghviniashvili commented 3 years ago

Hi @jhofman ,

I managed to draw the two frames using vega-lite.

And also updating between these two frames. Here is the video:

https://user-images.githubusercontent.com/6615532/114000075-b3c6b980-986b-11eb-8542-3db75eaaa1e4.mov

My thoughts about vega,

sharlagelfand commented 3 years ago

Reading around a bit about animation with Vega (seems like a popular request!) (side note - someone linked SandDance which I didn't know about, so now I "get" the datamation_sanddance() name 😄)

One thing that was linked is gemini, which is a grammar for animating between vega/vega-lite charts. Seems like it may still be in the prototype stage, but has a paper to accompany it.

On the R side, vegawidget looks like the best option to explore - I'll dig into it today.

jhofman commented 3 years ago

@sharlagelfand, excellent sleuthing, and sorry to have not explained the sanddance connection before! sounds good on exploring vegawidget. would also be curious to know if ggvis outputs vega(lite) specs.

turns out we got the same lead on gemini from talk to a friend yesterday afternoon. and the same authors have a nice paper on creating animations to show different types of animations (mean, max, sd, etc.). (see #18.)

so the plan is that @giorgi-ghviniashvili is going to:

  1. Read the papers behind gemini and aggregate animations from Younghoon Kim & co.
  2. Try to use gemini to animate between two frames in the salary datamation.
  3. If that's successful, think about whether the aggregate animations can be implemented with gemini as well, or if it has limitations that would prevent us from using it if/when we want to do more "custom" animations.
jhofman commented 3 years ago

It's also possible that Altair is worth looking at.

There is an R package for Altair that is called altair (with a lowercase A, somewhat confusingly). But it seems like this might actually call out to Python just to generate vegalite?

sharlagelfand commented 3 years ago

Some initial exploration of vegawidget: https://github.com/jhofman/datamations/blob/vegawidget-exploration/sandbox/vegawidget/vegawidget_exploration.R, looking at how to create a spec in R (+ how to visualize it in R or export it to JSON) and where the spec could come in based on existing coordinates data that is calculated by datamations already

giorgi-ghviniashvili commented 3 years ago

Hi @jhofman.

I managed to animate with gemini.

https://user-images.githubusercontent.com/6615532/114171559-7df60380-9945-11eb-9f59-7e1bf1df07a5.mov