Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +22 -17
src/streamlit_app.py
CHANGED
|
@@ -56,45 +56,50 @@ else:
|
|
| 56 |
|
| 57 |
st.divider()
|
| 58 |
|
| 59 |
-
# 5. ANA GRAFİK (
|
| 60 |
st.markdown(f"## 📈 {year} Analizi / Analysis")
|
| 61 |
-
|
| 62 |
|
| 63 |
-
with
|
| 64 |
if not filtered_df.empty:
|
| 65 |
-
|
| 66 |
-
|
|
|
|
| 67 |
ax1.fill_between(filtered_df['Date'], filtered_df['GLD'], color='gold', alpha=0.1)
|
|
|
|
| 68 |
y_min, y_max = filtered_df['GLD'].min(), filtered_df['GLD'].max()
|
| 69 |
ax1.set_ylim(y_min * 0.98, y_max * 1.02)
|
|
|
|
| 70 |
st.pyplot(fig1)
|
| 71 |
-
plt.close(fig1)
|
| 72 |
|
| 73 |
st.markdown(f"#### 📝 Not: Bu grafik {year} yılındaki günlük fiyat hareketlerini gösterir. / Note: This chart shows daily price movements in {year}.")
|
| 74 |
st.divider()
|
| 75 |
|
| 76 |
-
# 6. DİĞER GRAFİKLER
|
| 77 |
col_left, col_right = st.columns(2)
|
| 78 |
|
| 79 |
with col_left:
|
| 80 |
st.markdown("### 🎯 Dağılım / Distribution")
|
| 81 |
-
fig2, ax2 = plt.subplots(figsize=(5, 3))
|
| 82 |
sns.kdeplot(x=filtered_df['GLD'], fill=True, color="orange", ax=ax2)
|
| 83 |
st.pyplot(fig2)
|
| 84 |
plt.close(fig2)
|
| 85 |
|
| 86 |
with col_right:
|
| 87 |
st.markdown("### 🌡️ Korelasyon / Correlation")
|
| 88 |
-
fig3, ax3 = plt.subplots(figsize=(5, 3))
|
| 89 |
num_df = filtered_df.select_dtypes(include=['number'])
|
| 90 |
-
sns.heatmap(num_df.corr(), annot=True, cmap='YlOrBr', ax=ax3, annot_kws={"size":
|
| 91 |
st.pyplot(fig3)
|
| 92 |
plt.close(fig3)
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
st.divider()
|
| 58 |
|
| 59 |
+
# 5. ANA GRAFİK (Sabit Konteyner)
|
| 60 |
st.markdown(f"## 📈 {year} Analizi / Analysis")
|
| 61 |
+
main_container = st.container()
|
| 62 |
|
| 63 |
+
with main_container:
|
| 64 |
if not filtered_df.empty:
|
| 65 |
+
# Titremeyi azaltmak için figürü fonksiyona bağlamadan direkt çiziyoruz
|
| 66 |
+
fig1, ax1 = plt.subplots(figsize=(8, 2.8))
|
| 67 |
+
ax1.plot(filtered_df['Date'], filtered_df['GLD'], color='gold', linewidth=2)
|
| 68 |
ax1.fill_between(filtered_df['Date'], filtered_df['GLD'], color='gold', alpha=0.1)
|
| 69 |
+
|
| 70 |
y_min, y_max = filtered_df['GLD'].min(), filtered_df['GLD'].max()
|
| 71 |
ax1.set_ylim(y_min * 0.98, y_max * 1.02)
|
| 72 |
+
|
| 73 |
st.pyplot(fig1)
|
| 74 |
+
plt.close(fig1)
|
| 75 |
|
| 76 |
st.markdown(f"#### 📝 Not: Bu grafik {year} yılındaki günlük fiyat hareketlerini gösterir. / Note: This chart shows daily price movements in {year}.")
|
| 77 |
st.divider()
|
| 78 |
|
| 79 |
+
# 6. DİĞER GRAFİKLER (YAN YANA)
|
| 80 |
col_left, col_right = st.columns(2)
|
| 81 |
|
| 82 |
with col_left:
|
| 83 |
st.markdown("### 🎯 Dağılım / Distribution")
|
| 84 |
+
fig2, ax2 = plt.subplots(figsize=(5, 3.5))
|
| 85 |
sns.kdeplot(x=filtered_df['GLD'], fill=True, color="orange", ax=ax2)
|
| 86 |
st.pyplot(fig2)
|
| 87 |
plt.close(fig2)
|
| 88 |
|
| 89 |
with col_right:
|
| 90 |
st.markdown("### 🌡️ Korelasyon / Correlation")
|
| 91 |
+
fig3, ax3 = plt.subplots(figsize=(5, 3.5))
|
| 92 |
num_df = filtered_df.select_dtypes(include=['number'])
|
| 93 |
+
sns.heatmap(num_df.corr(), annot=True, cmap='YlOrBr', ax=ax3, annot_kws={"size": 8})
|
| 94 |
st.pyplot(fig3)
|
| 95 |
plt.close(fig3)
|
| 96 |
|
| 97 |
+
st.divider()
|
| 98 |
+
|
| 99 |
+
# 7. VERİ TABLOSU (Artık Hep Açık)
|
| 100 |
+
st.markdown("### 📋 Veri Tablosu / Data Table")
|
| 101 |
+
# Verileri Gör kısmını direkt tablo olarak bastık, expander'ı kaldırdık
|
| 102 |
+
st.dataframe(filtered_df.head(10), use_container_width=True)
|
| 103 |
+
|
| 104 |
+
csv = filtered_df.to_csv(index=False).encode('utf-8')
|
| 105 |
+
st.download_button("📥 Veriyi İndir / Download CSV", data=csv, file_name=f'gold_{year}.csv')
|