# Pyplot size problem

**URL:** <https://discuss.streamlit.io/t/pyplot-size-problem/13640>\
**Category:** Using Streamlit\
**Tags:** matplotlib\
**Created:** [June 4, 2021, 8:50am UTC](https://discuss.streamlit.io/t/pyplot-size-problem/13640 "2021-06-04T08:50:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nabs33](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nabs33](https://discuss.streamlit.io/u/Nabs33)\
**Post date:** [June 4, 2021, 8:50am UTC](https://discuss.streamlit.io/t/pyplot-size-problem/13640/1 "2021-06-04T08:50:51Z")

</div>

Hi,

I’m a new streamlit user, i’m making my first dashboard and I have a problem with the size of one of my plots

This is the code

> fig = plt.plot(dfpatient2[‘Datetime’], dfpatient2[select])  
> plt.gcf().autofmt\_xdate()  
> st.pyplot()

And this is a screenshot of my problem (the plot is too big…)

 ![streamlitsize](https://global.discourse-cdn.com/streamlit/original/2X/1/1a226140fd4da96179396d7e9739be61775736fa.png)

Thanks

---

<div class="post-metadata">

**Author:** ![snehankekre](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/snehankekre/32/6504_2.png) [@snehankekre](https://discuss.streamlit.io/u/snehankekre)\
**Post date:** [June 4, 2021, 9:58am UTC](https://discuss.streamlit.io/t/pyplot-size-problem/13640/2 "2021-06-04T09:58:57Z")

</div>

Hi @Nabs33, welcome to the Streamlit community!! 👋 🥳

As you would with any matplotlib figure, you can customize the size of the figure by specifying the width and height (in inches) to the `figsize` parameter of `plt.figure()`. E.g. `fig = plt.figure(figsize=(7,3))`.

Here’s example showing how to set a custom figsize when plotting from a dataframe `ts`:

```python
import streamlit as st
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# set figsize globally with plt.rcParams["figure.figsize"] = (7, 3)

ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()

fig = plt.figure(figsize=(7,3)) # try different values
ax = plt.axes()

ax.plot(ts) # replace with ax.plot(dfpatient2[‘Datetime’], dfpatient2[select])
plt.gcf().autofmt_xdate()
st.pyplot(fig)

```

You can experiment with different values in `figsize` to see what works best for your use case. Let us know if this helps!

_Happy Streamlit-ing!_ 🎈  
_Snehan_

---

<div class="post-metadata">

**Author:** ![randyzwitch](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/randyzwitch/32/58772_2.png) [@randyzwitch](https://discuss.streamlit.io/u/randyzwitch)\
**Post date:** [August 15, 2022, 8:34pm UTC](https://discuss.streamlit.io/t/pyplot-size-problem/13640/3 "2022-08-15T20:34:14Z")

</div>


