Skip to content

Instantly share code, notes, and snippets.

@chendaniely
Last active December 4, 2020 17:03
Show Gist options
  • Save chendaniely/ece0cc5cd2324750461575fd1b9ab026 to your computer and use it in GitHub Desktop.
Save chendaniely/ece0cc5cd2324750461575fd1b9ab026 to your computer and use it in GitHub Desktop.
Altair in Rmd
---
title: "rmd altair"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
reticulate::use_condaenv()
reticulate::py_config()
```
```{python}
import altair as alt
from vega_datasets import data
chart = alt.Chart(data.cars.url).mark_point().encode(
x='Horsepower:Q',
y='Miles_per_Gallon:Q',
color='Origin:N'
)
```
```{python}
type(chart)
```
```{python}
chart.save('chart.html')
```
<iframe src="chart.html"></iframe>
```{r}
htmltools::includeHTML("chart.html")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment