Creating Charts
Streamlit has simple chart functions and supports popular visualization libraries.
Built-in charts:
import streamlit as st
import pandas as pd
df = pd.DataFrame({"x": [1, 2, 3], "y": [10, 20, 15]})
st.line_chart(df)
st.bar_chart(df)
st.area_chart(df)
These are quick and easy - just pass a DataFrame.
For more control, use Plotly, Altair, or Matplotlib:
import plotly.express as px
fig = px.scatter(df, x="x", y="y", title="My Chart")
st.plotly_chart(fig)
Matplotlib works too:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(df["x"], df["y"])
st.pyplot(fig)
Choose based on your needs - built-in for speed, libraries for customization.
I cover visualization in my Streamlit course.