Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions app_5_eda_sp500_stock/sp500-app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down