Scaling with st.pyplot


I have a matplotlib generate plot that is not scaling as desired within streamlit; I havent found a way to properly scale the width of a matplotlib figure in streamlit.

I tried setting the figsize within mpl itself, but alll I get was an extremely small image with unreadable labels.

any assistance?

The public app is here:

But basically I want the plot to be much wider for easier visualization

Hi @alexkingsing,

I think settings the page layout to wide is what you are looking for!

Additionally you might want to format the labels and figure size in your mpl plot a bit, but I’ll leave that up to you :slight_smile:

@alexkingsing Hi mate, look, if you problem it’s with you chart scale (i had the same problem before) a solution i see is the following below. In short, you gonna need to create two variables with max() and min() values of you data, so the fuction from you data could centralize in your chart. Keep in mind I’m using Altair instead of Matplotlib to plot my charts do show this example!!! But i think the idea would be the same, but you could check here API reference — Streamlit 0.80.0 documentation to see if fits for you purpose.

y_data_max = df['My data'].max()
y_data_min = df['My data'].min()

base_data = alt.Chart(df, title="The title i want to use").properties(width=1000, height=300)

My Data Chart = base_data.mark_line(point=True, color='black').encode(
     alt.X('name_of_your_column_you_want_to_use_in_X_axis', type='quantitative', title='X axis'),
     alt.Y('name_of_your_column_you_want_to_use_in_Y_axis', type='quantitative', title='Y axis', scale=alt.Scale(domain=(y_data_min, y_data_max )))