library(reticulate) # py_install(c("altair", "vega_datasets", "pandas"))
```{python, altair.fig.width=800, altair.fig.height=300} import altair as alt from vega_datasets import data
source = data.movies.url
alt.Chart(source).mark_bar().encode( alt.X("IMDB_Rating:Q", bin=True), y='count()', )
## Compound charts ```{python} 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] }) fig1 = alt.Chart(source).mark_bar().encode( x='a', y='b' ) fig2 = alt.Chart(source).mark_bar().encode( x='a', y='b', color='b:N' ) fig3 = alt.Chart(source).mark_bar().encode( x='a', y='b', color='a:N' )
#| label: first (fig1 | fig2).properties(title="This is the First Chart")
#| label: second (fig2 | fig1).properties(title="This is the Second Chart")
#| label: third (fig2 | fig1 | fig3).properties(title="This is the Third Chart")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.