ESMATUGBA commited on
Commit
99234f4
·
verified ·
1 Parent(s): bbc16af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -16
app.py CHANGED
@@ -56,45 +56,51 @@ else:
56
 
57
  st.divider()
58
 
59
- # 5. ANA GRAFİK (Titremeyi önlemek için empty container kullanıyoruz)
60
  st.markdown(f"## 📈 {year} Analizi / Analysis")
61
- main_chart_placeholder = st.empty() # Boş alan ayırır, titremeyi azaltır
62
 
63
- with main_chart_placeholder.container():
64
  if not filtered_df.empty:
65
- fig1, ax1 = plt.subplots(figsize=(8, 2.5))
66
- ax1.plot(filtered_df['Date'], filtered_df['GLD'], color='gold', linewidth=1.5)
 
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) # Hafızayı temizle
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": 7})
91
  st.pyplot(fig3)
92
  plt.close(fig3)
93
 
94
- # 7. VERİ TABLOSU (HATA DÜZELTİLDİ)
95
- with st.expander("Verileri Gör / View Data"):
96
- # Hata veren width=None yerine 'stretch' kullandık
97
- st.dataframe(filtered_df.head(), width=1200) # Sabit piksel veya 'stretch' uyarısı için
98
- csv = filtered_df.to_csv(index=False).encode('utf-8')
99
- st.download_button("📥 İndir / Download", data=csv, file_name=f'gold_{year}.csv')
 
 
 
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')
106