Created
January 23, 2020 17:15
-
-
Save ijlyttle/aa314d02b5f7f85702ea2a648393b21f to your computer and use it in GitHub Desktop.
Altair + reticulate + vegawidget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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