-
Notifications
You must be signed in to change notification settings - Fork 8
Translator from ggplot2 to Vega Lite
Vega-Lite offers an interactive grammar of graphics rendered in the browser, but it requires you to build a JSON specification. As Tom MacWright (Observable) recently tweeted, "javascript visualization needs a library that lets users write literally ggplot2 and ease them into javascript from there." We propose to develop this capability to use Vega-Lite.
The ggplotly()
function in Carson Sievert's plotly package is a tremendous success, allowing the user to convert a ggplot2 object into a plotly chart-specification. Our goal is extend this success by bringing the same capability to Vega-Lite, itself built on an implementation of the grammar-of-graphics.
We see this project as a collaboration between Haley Jeppson, who has expertise in R, with the ggplot2 architecture and experience with Vega-Lite -- and the GSOC student, who we imagine to have a computer-science background, with experience in automatic code-generation, perhaps along the lines what the Python Altair project has implemented.
At the end of three months, we expect a functional R package that will translate a ggplot object into a Vega-Lite specification. We expect that we will start with non-faceted charts, and implement a subset of geoms such as points, lines, and bars. Haley will be responsible for the creation and maintenance of the R package - the GSOC student will be responsible for devising a maintainable framework that could maintain "connections" with both the Vega-Lite schema and the ggplot2 object, even as each evolves.
Vega and Vega-Lite provide an implementation of an interactive grammar-of-graphics. These packages, and JavaScript visualization in general, can be made more-accessible by offering an automatic translation of a ggplot2 object into a Vega-Lite specification.
Students, please contact mentors below after completing at least one of the tests below.
- Haley Jeppson (hjeppson@iastate.edu) is the author of the R package ggmosaic (CRAN), as well as a contributor to altair, and has previous GSOC experience with rstats-gsoc in 2017.
- Ian Lyttle (ian.lyttle@se.com) is the author of the R package vegawidget (CRAN), as well as altair (wrapper to Python Altair) and vegablock (in development).
- Heike Hofmann (hofmann@iastate.edu) is an authority on interactive visualization and an author of many R pacakges, most-recently including ggmosaic, geomnet, gglogo and x3ptools (CRAN). She has been a GSOC mentor for many years.
Students, please do one or more of the following tests before contacting the mentors above.
As a warm-up, install ggplot2 and vegawidget. Using each framework, create a scatterplot for one of the x-y sets in the datasets::anscombe
dataset.
Easy: Create an Observable notebook (you may have to create an account for yourself) that implements this interactive brushing example. You may wish to use Dominik Moritz' Hello Vega Embed notebook as a starting point for how to import vega-embed into Observable. What happens if you specify Cylinders
to be a "nominal"
variable, rather than an "ordinal"
variable?
Medium: Write a document (perhaps using R Markdown), roughly equivalent to a blog post, reviewing the approach the Altair project has implemented for automatic code-generation. We are particularly interested an assessment of the techniques the Altair project uses for automatic code-generation, given the Vega-Lite schema. Quoting the Altair documentation:
One of the nice features of Altair is that this low-level object hierarchy is not constructed by hand, but rather programmatically generated from the Vega-Lite schema, using the
generate_schema_wrapper.py
script that you can find in Altair’s repository.
Let us know some first ideas about how you might implement this using R - keeping in mind that R has interfaces to other languages including, but not limited to, Python (reticulate) and JavaScript (V8).
Hard: Create an R-package that contains a function that will translate a scatterplot ggplot-object into a Vega-Lite specification (you can use Anscombe as an example). As a stretch, extend your function so that it will translate a bar-chart (you can use this as an example). We would like to assess your first-pass at an R-package that has a translation function; please make this R-package available on GitHub.
-
Name: Yu Xia (Kurt), Github
Email: z5212108@ad.unsw.edu.au
University: Bachelor of Computer Science @ UNSW
Solution to All Tests: Observable Notebook
Students, please post a link to your test results here.