HELP! UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure

Hello, I am trying to get my streamlit page to show all of my graphs created by using matplotlib. I keep getting the same error, “UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure,” and although I have tried many options nothing has helped. How do I fix this? My site keeps coming up blank. I want all of my graphs to appear on the site. I am also using anaconda.

Here’s an example of one of the graphs.
fig, ax = plt.subplots()

x = [‘Consecutive Reads’, ‘Sequential Reads’]

y = [consec_read_pct3, consec_read_pct4]

ax.bar(x, y)

ax.set_ylabel(‘Percentage’)

ax.set_ylim(0, 100)

plt.show()

Hi @aby_k24,

Streamlit does not us plt.show() to render plots. You need to pass the figure to a Streamlit command such as st.write(fig) or st.pyplot(fig) (documentation here).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.