Matplotlib charts


You can embed any matplotlib pyplot chart simply with app.pyplot:

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [1, 4, 2, 3])
app.pyplot(fig, title="My simple line chart")

By default the chart will be an interactive altair chart, to turn off the interactivity and embed just as an image. static=True. You'll also need altair_saver installed with pip install altair_saver.


You can also embed any seaborn chart as well:

import seaborn as sns

tips = sns.load_dataset("tips")
fig = sns.relplot(
    x="total_bill", y="tip", col="time",
    hue="smoker", style="smoker", size="size",