omniverse1 commited on
Commit
8a9810a
·
verified ·
1 Parent(s): 6eb2763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -186,16 +186,19 @@ def analyze_sentiment(asset_name):
186
  ax.plot(x, y, color='lightgray', linewidth=10, solid_capstyle='round', zorder=1)
187
 
188
  # Segments (Matching the image)
 
 
189
  # 1. Red: -1.0 to -0.5
190
  ax.fill_between(x[75:], y[75:], 0, where=x[75:]<=-0.5, color='#F08080', alpha=0.9, linewidth=0, zorder=2)
191
- # 2. Yellow/Orange: -0.5 to 0.0
192
  ax.fill_between(x[50:75], y[50:75], 0, where=x[50:75]<0, color='#FFD700', alpha=0.9, linewidth=0, zorder=2)
193
  # 3. Light Gray: 0.0 to 0.5 (Neutral)
194
  ax.fill_between(x[25:50], y[25:50], 0, where=x[25:50]>0, color='#D3D3D3', alpha=0.9, linewidth=0, zorder=2)
195
  # 4. Light Green: 0.5 to 1.0
196
  ax.fill_between(x[:25], y[:25], 0, where=x[:25]>=0.5, color='#90EE90', alpha=0.9, linewidth=0, zorder=2)
197
 
198
- # Draw Needle (Pointer) - Mengikuti warna kuning pada gambar referensi
 
199
  needle_angle = np.pi * (1 - (sentiment_score + 1) / 2)
200
  needle_x = 0.8 * np.cos(needle_angle)
201
  needle_y = 0.8 * np.sin(needle_angle)
@@ -216,6 +219,7 @@ def analyze_sentiment(asset_name):
216
 
217
  # Trend indicator (panah bawah/atas kecil di bawah skor)
218
  trend_arrow = '▲' if sentiment_score > 0.0 else '▼' if sentiment_score < 0.0 else ''
 
219
  ax.text(0.0, -0.18, f"{trend_arrow}{abs(sentiment_score):.3f}", ha='center', va='center',
220
  fontsize=14, color=score_color, zorder=7)
221
 
@@ -227,7 +231,7 @@ def analyze_sentiment(asset_name):
227
  ax.text(1, 0, "1", ha='center', va='top', fontsize=10, color='black')
228
 
229
  # Add Title
230
- ax.set_title(f'{asset_name} Market Sentiment (Simulated)', color='black', pad=20)
231
 
232
  # Remove axes
233
  ax.axis('off')
 
186
  ax.plot(x, y, color='lightgray', linewidth=10, solid_capstyle='round', zorder=1)
187
 
188
  # Segments (Matching the image)
189
+ # Warna arc harus dicocokkan dengan gambar
190
+
191
  # 1. Red: -1.0 to -0.5
192
  ax.fill_between(x[75:], y[75:], 0, where=x[75:]<=-0.5, color='#F08080', alpha=0.9, linewidth=0, zorder=2)
193
+ # 2. Yellow/Orange: -0.5 to 0.0 (Ini adalah segmen yang terisi pada gambar untuk skor negatif)
194
  ax.fill_between(x[50:75], y[50:75], 0, where=x[50:75]<0, color='#FFD700', alpha=0.9, linewidth=0, zorder=2)
195
  # 3. Light Gray: 0.0 to 0.5 (Neutral)
196
  ax.fill_between(x[25:50], y[25:50], 0, where=x[25:50]>0, color='#D3D3D3', alpha=0.9, linewidth=0, zorder=2)
197
  # 4. Light Green: 0.5 to 1.0
198
  ax.fill_between(x[:25], y[:25], 0, where=x[:25]>=0.5, color='#90EE90', alpha=0.9, linewidth=0, zorder=2)
199
 
200
+
201
+ # Draw Needle (Pointer)
202
  needle_angle = np.pi * (1 - (sentiment_score + 1) / 2)
203
  needle_x = 0.8 * np.cos(needle_angle)
204
  needle_y = 0.8 * np.sin(needle_angle)
 
219
 
220
  # Trend indicator (panah bawah/atas kecil di bawah skor)
221
  trend_arrow = '▲' if sentiment_score > 0.0 else '▼' if sentiment_score < 0.0 else ''
222
+ # Text di bawah score (misalnya ▼-0.123)
223
  ax.text(0.0, -0.18, f"{trend_arrow}{abs(sentiment_score):.3f}", ha='center', va='center',
224
  fontsize=14, color=score_color, zorder=7)
225
 
 
231
  ax.text(1, 0, "1", ha='center', va='top', fontsize=10, color='black')
232
 
233
  # Add Title
234
+ ax.set_title(f'{ticker} Market Sentiment (Simulated)', color='black', pad=20)
235
 
236
  # Remove axes
237
  ax.axis('off')