Hi @Zylatis, I’m sorry to hear you’re having trouble with resizing matplotlib figures.
Could you share a working example or code a snippet where you are trying unsuccessfully to resize a figure? We could try figuring it out together.
In the meantime, I put together a minimal example based on a matplotlib tutorial. I vary the values of the width
and height
parameters in figsize
using sliders:
import streamlit as st
import matplotlib.pyplot as plt
cat = ["bored", "happy", "bored", "bored", "happy", "bored"]
dog = ["happy", "happy", "happy", "happy", "bored", "bored"]
activity = ["combing", "drinking", "feeding", "napping", "playing", "washing"]
width = st.sidebar.slider("plot width", 1, 25, 3)
height = st.sidebar.slider("plot height", 1, 25, 1)
fig, ax = plt.subplots(figsize=(width, height))
ax.plot(activity, dog, label="dog")
ax.plot(activity, cat, label="cat")
ax.legend()
st.pyplot(fig)
Click on the GIF below to see resizing in action:
Happy Streamlit-ing!
Snehan