Skip to content

Instantly share code, notes, and snippets.

@ijlyttle
Created January 23, 2020 17:15
Show Gist options
  • Save ijlyttle/aa314d02b5f7f85702ea2a648393b21f to your computer and use it in GitHub Desktop.
Save ijlyttle/aa314d02b5f7f85702ea2a648393b21f to your computer and use it in GitHub Desktop.
Altair + reticulate + vegawidget
---
title: "Altair-reticulate"
output: html_document
---
```{r load_packages}
library(vegawidget)
library(reticulate)
```
```{python Altair}
import altair as alt
import pandas as pd
source = pd.DataFrame({
'a': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
'b': [28, 55, 43, 91, 81, 53, 19, 87, 52]
})
chart1 = alt.Chart(source).mark_bar().encode(
x='a',
y='b'
)
vw = chart1.to_json()
```
```{r display}
as_vegaspec(py$vw)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment