Course contentsShow
← Data Science
Lesson 1333 of 2,14533. Advanced Visualization TechniquesFree lesson

Displaying Charts and Tables in Streamlit

Embed Matplotlib, Plotly, and Altair charts, plus display dataframes with sorting and filtering capabilities.

Displaying Charts and Tables in Streamlit

You'll learn how to embed different visualization libraries and display interactive dataframes in your Streamlit dashboards.

Now that you understand Streamlit's layout and widgets, it's time to show the actual data insights. Streamlit makes it remarkably easy to display charts from multiple visualization libraries and dataframes with built-in interactivity—no complex HTML or JavaScript required.

Core Concept

Think of Streamlit as a universal display frame that accepts artwork from different artists (Matplotlib, Plotly, Altair). You create your visualization using your preferred library, then simply pass it to Streamlit's display functions. For dataframes, Streamlit adds free interactive features like sorting and filtering automatically.

Embedding Charts

Matplotlib charts use st.pyplot():

import streamlit as st
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [4, 5, 6])
st.pyplot(fig)

Plotly charts use st.plotly_chart():

import plotly.express as px
fig = px.scatter(df, x='column_a', y='column_b')
st.plotly_chart(fig)

Altair charts use st.altair_chart():

import altair as alt
chart = alt.Chart(df).mark_circle().encode(x='x', y='y')
st.altair_chart(chart)

Interactive Dataframes

Use st.dataframe() for sortable, scrollable tables:

st.dataframe(df)  # Users can click columns to sort

For static tables without interactivity, use st.table(df).

The beauty here? Plotly and Altair charts retain their native interactivity (hover, zoom, pan), while dataframes automatically get sorting capabilities—turning static reports into explorable dashboards with minimal code.

Key Takeaway: Streamlit provides dedicated functions for each visualization library and automatically adds interactivity to dataframes, letting you focus on insights rather than interface mechanics.