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
fig, ax = plt.subplots()
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
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),
# Now we can send the fig to pyplot
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!