...

/

Combining Multiple Charts

Combining Multiple Charts

Learn how to combine multiple charts in Altair.

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:

  1. A bar chart showing the total sales for each product category:

Press + to interact
import pandas as pd
import altair as alt
import os
df = 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')
...