Giter Club home page Giter Club logo

altair's Introduction

lifecycle CRAN status Travis build status

altair

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.

Installation

A development version is available from GitHub:

# install.packages("devtools")
devtools::install_github("vegawidget/altair") 

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.

  1. Python must be installed on your system. I recommend using a Conda installation; Miniconda works well and installs more-quickly than Anaconda.

    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.

  2. 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.

  3. Install Altair into your "r-reticulate" environment using altair::install_altair().

You may wish to add a line like this to the .First() function in your .Rprofile:

reticulate::use_condaenv("r-reticulate")

The use_condaenv() function is called to provide a hint to reticulate on which Python environment to use.

Example

library("altair")

vega_data <- import_vega_data()

chart <- 
  alt$Chart(r_to_py(vega_data$cars()))$
  encode(
    x = "Horsepower:Q",
    y = "Miles_per_Gallon:Q",
    color = "Origin:N"
  )$
  mark_point()

chart

Some things to keep in mind:

  • Where you see a . in the Python examples, use a $ instead.

  • Any data frames you provide as data arguments need to wrapped by r_to_py().

  • 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.

Articles

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

Gallery:

  • An adaptation to R of the Altair Example Gallery, to demonstrate (not least to ourselves) that we are not missing any of the expressiveness of the Python API. You may be interested in the Interactive Charts examples.

Examples:

Field Guides:

Acknowledgements

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

  • htmlwidgets: R framework to work with JavaScript visualizations

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:

  • Alicia Schep has contributed the concatenation functions, as well as sorted out many of the Python, JavaScript, and package-API issues.

  • Haley Jeppson has adapted the Altair Example Gallery to R.

  • Heike Hofmann has been an invaluable advisor, providing incisive feedback, and insight into the fundamentals of interactive graphics.

Contributing

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

This project also has a Contributing Guide.

altair's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.