Combining Multiple Charts
Learn how to combine multiple charts in Altair.
We'll cover the following...
Altair enables us to combine multiple charts into a single compound chart. Altair supports the following compound charts: layering, horizontal concatenation, vertical concatenation, and repeated charts.
We’ll use the sales dataset to illustrate how to combine multiple charts in Altair. We’ll produce two charts:
A bar chart showing the total sales for each product category:
Press + to interact
import pandas as pdimport altair as altimport osdf = pd.read_csv('data/sales.csv')chart1 = alt.Chart(df).mark_bar(color='lightgrey').encode(x = 'Product Category:N',y = 'sum(Sales):Q')chart1.save('chart.html')os.system('cat chart.html')
...