PyplotGlobalUseWarning

Hey @Racchel. I might be able to help suppress the error without setting that option. If you feel itā€™s okay to suppress the deprecation warning, thatā€™s fine. However, itā€™s possible we can change the script and undo the suppression.

Like @randyzwitch says, the warning pops up because an argument is not being sent to st.pyplot. When the argument isnā€™t specified, we internally call plt.savefig rather than on the figure itself. This works so long as you are looking at the graph on a single browser tab. No other tabs should be open on that page, and, if deployed online, multiple people will not be able to access it at the same time.

I tried the code you provided, but an error appears unrelated.

>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.figure(figsize=(15,5))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot unpack non-iterable Figure object

I think to fix this we need to use the plt.subplots command.

fig, ax = plt.subplots()
# ...
st.pyplot(fig)

Using plt.subplots(), we now need to do operations on ax instead of plt. For seaborn, most plotting have an ax command to perform the operations on (instead of plt). Lastly, thereā€™s a slight change in setting the title and y_label.

I canā€™t test this code because I do not have the data, but I think the following changes will work. Note the use of ax in each line.

fig, ax = plt.subplots(figsize=(15,5))

# Seaborn Operations (Note ax=ax)
sns.lineplot(x="DIAS_RESTANTES_PARA_VIAGEM", y="min", data=df_voos_originais, ci=None, palette="muted", label='min', ax=ax)
sns.lineplot(x="DIAS_RESTANTES_PARA_VIAGEM", y="max", data=df, ci=None, palette="muted", label='max', ax=ax)

# See Operations on Axes https://matplotlib.org/3.1.1/api/axes_api.html
ax.set_title(titulo, fontweight="bold", fontsize=16, pad=20),
ax.set_ylabel('Cost'))

# Now we can send the fig to pyplot
st.pyplot(fig)

If the above works, then you should be able to remove st.set_option('deprecation.showPyplotGlobalUse', False) Andā€¦fingers crossedā€¦no warning should appear!

I hope that helps!