Visual results are the heart of most data apps, and Streamlit renders the libraries you already know.
Streamlit has quick built-in charts that take a DataFrame and need no plotting library code:
st.line_chart(df, x="date", y=["a", "b"])st.area_chart,st.bar_chart(withhorizontal=Trueorstack=False),st.scatter_chartst.map(df)plots points fromlat/lon(orlatitude/longitude) columns on a map
They are built on Altair and are interactive (hover, zoom), but offer limited customization.
For full control, render a figure from your plotting library:
st.plotly_chart(fig): interactive Plotly figures; withon_select="rerun"it returns the user's selected points.st.altair_chart(chart)andst.vega_lite_chart.st.pyplot(fig): Matplotlib and seaborn figures as static images. Pass the figure object explicitly instead of relying on global pyplot state, which is shared between sessions.st.pydeck_chartfor advanced 3D maps,st.graphviz_chartfor graphs.
Charts stretch to the container width by default; use width= and height= to size them, and put them inside columns or tabs for layout.
Because the script reruns on each interaction, chart code reruns too. Build figures from cached data so redrawing stays fast, and avoid generating heavy Matplotlib figures for every keystroke in a text input.
Example
import numpy as np
import pandas as pd
import plotly.express as px
import matplotlib.pyplot as plt
import streamlit as st
rng = np.random.default_rng(0)
df = pd.DataFrame({"day": pd.date_range("2026-01-01", periods=60),
"visits": rng.poisson(200, 60).cumsum(),
"signups": rng.poisson(20, 60).cumsum()})
st.line_chart(df, x="day", y=["visits", "signups"]) # built-in
fig = px.scatter(df, x="visits", y="signups", title="Visits vs signups")
st.plotly_chart(fig) # interactive
mfig, ax = plt.subplots()
ax.hist(np.diff(df.visits), bins=15)
st.pyplot(mfig) # static image
pts = pd.DataFrame({"lat": [59.91, 48.86], "lon": [10.75, 2.35]})
st.map(pts, zoom=3)Remember
- Built-in
st.line_chart,bar_chart,scatter_chartandmaptake DataFrames directly st.plotly_chart,st.altair_chartandst.pyplotrender library figures- Pass Matplotlib figure objects explicitly to
st.pyplot
Watch out for
- Calling
st.pyplot()with no figure, relying on pyplot's global state shared across users.