Display a matplotlib.pyplot figure.
Function signature

st.pyplot(fig=None, clear_figure=None, **kwargs)


fig (Matplotlib Figure)

The figure to plot. When this argument isn't specified, this function will render the global figure (but this is deprecated, as described below)

clear_figure (bool)

If True, the figure will be cleared after being rendered. If False, the figure will not be cleared after being rendered. If left unspecified, we pick a default based on the value of fig.

  • If fig is set, defaults to False.
  • If fig is not set, defaults to True. This simulates Jupyter's approach to matplotlib rendering.

**kwargs (any)

Arguments to pass to Matplotlib's savefig function.

Was this page helpful?

editSuggest edits

Still have questions?

Our forums are full of helpful information and Streamlit experts.