The goal of altair is to help you build Vega-Lite visualizations. Using the reticulate package, it provides an interface to the Altair Python package. This approach is distinct from efforts to build a native R interface to Vega-Lite, by Bob Rudis and coworkers: the vegalite package, which has inspired this effort.
In this documentation, the capitalized word Altair shall refer to the Python package; the lower-case word altair shall refer to this R package.
A development version is available from GitHub:
Because you are using a Python package, you may have some additional installation steps. These steps are described in greater detail in the Installation article.
If you work in a corporate or institutional environment, you may have to specify the location of your SSL certificate, or deal with a proxy. The installation article has a section on this.
Create a Conda environment called
"r-reticulate". The reticulate folks recommend standardizing on a common name for all packages that use reticulate. For more information, there is a section in the installation article.
Install Altair into your
"r-reticulate" environment using
You may wish to add a line like this to the
.First() function in your
use_condaenv() function is called to provide a hint to reticulate on which Python environment to use.
Some things to keep in mind:
Where you see a
. in the Python examples, use a
Any data frames you provide as
data arguments need to wrapped by
In your data, columns that contain dots can be wrapped in square brackets in Altair specifications, e.g.
[Sepal.Width], to keep Altair from throwing an error.
These and other “gotchas” are compiled, along with workarounds, in an article: Field Guide to Python Issues.
The documentation for this package includes some articles:
Installation: some more-detailed instructions
Manifesto: an outline of some high-level development ideas, which may change from time to time
First Example: a walkthrough to get a first chart to work
View Composition: how to facet, add layers to, repeat, and concatenate charts
Interactive Examples: a set of examples that work towards linked-brushing of two scatterplots
This package rests on these foundations:
Altair: Python interface to Vega-Lite
reticulate: R framework to work with Python
Vega-Lite: a grammar of interactive graphics
As well, a particular debt is owed to the folks behind the vegalite package, as it provided a lot of the inspiration for these efforts.
This project is a collaborative effort. In addition to the principal author:
Heike Hofmann has been an invaluable advisor, providing incisive feedback, and insight into the fundamentals of interactive graphics.