diff --git a/app_5_eda_sp500_stock/sp500-app.py b/app_5_eda_sp500_stock/sp500-app.py index 749fa34c..94264e9c 100644 --- a/app_5_eda_sp500_stock/sp500-app.py +++ b/app_5_eda_sp500_stock/sp500-app.py @@ -64,15 +64,27 @@ def filedownload(df): # Plot Closing Price of Query Symbol def price_plot(symbol): - df = pd.DataFrame(data[symbol].Close) - df['Date'] = df.index - plt.fill_between(df.Date, df.Close, color='skyblue', alpha=0.3) - plt.plot(df.Date, df.Close, color='skyblue', alpha=0.8) - plt.xticks(rotation=90) - plt.title(symbol, fontweight='bold') - plt.xlabel('Date', fontweight='bold') - plt.ylabel('Closing Price', fontweight='bold') - return st.pyplot() + df = pd.DataFrame(data[symbol].Close) + df['Date'] = df.index + + # old method + # plt.fill_between(df.Date, df.Close, color='skyblue', alpha=0.3) + # plt.plot(df.Date, df.Close, color='skyblue', alpha=0.8) + # plt.xticks(rotation=90) + # plt.title(symbol, fontweight='bold') + # plt.xlabel('Date', fontweight='bold') + # plt.ylabel('Closing Price', fontweight='bold') + # return st.pyplot() + + # Changed to remove PyplotGlobalUseWarning + fig, ax = plt.subplots() + ax.fill_between(df.Date, df.Close, color='skyblue', alpha=0.3) + ax.plot(df.Date, df.Close, color='skyblue', alpha=0.8) + ax.tick_params(axis='x', rotation=90) + ax.set_title(symbol, fontweight='bold') + ax.set_xlabel('Date', fontweight='bold') + ax.set_ylabel('Closing Price', fontweight='bold') + return st.pyplot(fig) num_company = st.sidebar.slider('Number of Companies', 1, 5)