altair 3.1.1 on CRAN

R interface to Python Altair

Ian Lyttle , Haley Jeppson

A little over a year since its first introduction, we are pleased to announce the release on CRAN of altair, an R interface to the Altair Python package, which itself provides an interface to build Vega-Lite charts.

To minimize confusion with the Python package, we will use “altair” to refer to the R package, and “Altair” to refer to the Python package. As well, the first two numbers in the version of altair (currently 3.1.1) will mirror the first two numbers of the supported Altair version (currently 3.1.0).

By taking advantage of the reticulate package, altair exposes all of the functions in the Altair package. For example, this scatterplot has interactive scales (you can pan-and-zoom):


vega_data <- import_vega_data()

    x = "Horsepower",
    y = "Miles_per_Gallon",
    color = "Origin"

Here’s another example showing some of the data-transformation capabilities of Vega-Lite:

source <- 
    Activity = c("Sleeping", "Eating", "TV", "Work", "Exercise"),
    Time = c(8, 2, 4, 8, 2)

  transform_joinaggregate(TotalTime = "sum(Time)")$
  transform_calculate(ProportionOfTotal = "datum.Time / datum.TotalTime")$
    x = alt$X("ProportionOfTotal:Q", axis = alt$Axis(format = ".0%")),
    y = alt$Y(
      sort = alt$Sort(field = "ProportionOfTotal", order = "descending")

For more examples, please see our example gallery (starting here), where Haley Jeppson has reproduced the entire Altair gallery, demonstrating that whatever you can do in Python Altair, you can do also from R.

In general, wherever you see the . used in Python syntax, use a $ in R. Of course, to use altair, you will need to install Python. If you have Python installed already (we recommend Conda), you can use altair’s install_altair() function to install Altair.

A few words about the development philosophy of this package: our goal is to provide a faithful representation of the Altair package; we do not want to introduce any opinions beyond those introduced by the Altair authors. In other words, we would want that Jake Vanderplas could use this package and feel as much as possible “at home”. As such, we introduce very few functions of our own; these deal mainly with installation, view-composition, and rendering.

The rendering functions themselves are re-exported from the vegawidget package, which offers additional functions to provide interactivity using Shiny. We offer an online example, and an article.

Finally to acknowledge the support of collaborators, near and not-so-near:


For attribution, please cite this work as

Lyttle & Jeppson (2019, July 17). vegawidget: altair 3.1.1 on CRAN. Retrieved from

BibTeX citation

  author = {Lyttle, Ian and Jeppson, Haley},
  title = {vegawidget: altair 3.1.1 on CRAN},
  url = {},
  year = {2019}