AIEcosystem commited on
Commit
b5938f9
·
verified ·
1 Parent(s): 57aeb9d

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -8
src/streamlit_app.py CHANGED
@@ -136,12 +136,9 @@ def create_topic_word_bubbles(df_topic_data):
136
  y='weight',
137
  size='weight',
138
  color='topic',
139
- # --- MODIFICATION START ---
140
- # 1. Use 'word' for the text label on the chart
141
  text='word',
142
- # 2. Keep hover_name for tooltip on hover (optional, but good practice)
143
  hover_name='word',
144
- # --- MODIFICATION END ---
145
  size_max=80,
146
  title='Topic Word Weights (Bubble Chart)',
147
  color_discrete_sequence=px.colors.qualitative.Bold,
@@ -154,9 +151,10 @@ def create_topic_word_bubbles(df_topic_data):
154
  )
155
 
156
  fig.update_layout(
157
- xaxis_title="Entity/Word (Bubble size = Word Weight)",
158
  yaxis_title="Word Weight",
159
- xaxis={'tickangle': -45, 'showgrid': False, 'showticklabels': False}, # Hide x-axis labels since words are now labels
 
160
  yaxis={'showgrid': True},
161
  showlegend=True,
162
  plot_bgcolor='#f9f9f9',
@@ -165,11 +163,14 @@ def create_topic_word_bubbles(df_topic_data):
165
  margin=dict(t=50, b=100, l=50, r=10),
166
  )
167
 
168
- # Update traces to show the word text and adjust hover template
169
  fig.update_traces(
170
  # Position the text on top of the bubble
171
  textposition='middle center',
172
- # Customize hover template for better readability
 
 
 
173
  hovertemplate='<b>%{customdata[0]}</b><br>Weight: %{customdata[1]:.3f}<extra></extra>',
174
  marker=dict(line=dict(width=1, color='DarkSlateGrey'))
175
  )
 
136
  y='weight',
137
  size='weight',
138
  color='topic',
139
+ # Set text to the word
 
140
  text='word',
 
141
  hover_name='word',
 
142
  size_max=80,
143
  title='Topic Word Weights (Bubble Chart)',
144
  color_discrete_sequence=px.colors.qualitative.Bold,
 
151
  )
152
 
153
  fig.update_layout(
154
+ xaxis_title="Entity/Word",
155
  yaxis_title="Word Weight",
156
+ # Hide x-axis labels since words are now labels
157
+ xaxis={'tickangle': -45, 'showgrid': False, 'showticklabels': False},
158
  yaxis={'showgrid': True},
159
  showlegend=True,
160
  plot_bgcolor='#f9f9f9',
 
163
  margin=dict(t=50, b=100, l=50, r=10),
164
  )
165
 
166
+ # Update traces to show the word text, set the text position, and set text color
167
  fig.update_traces(
168
  # Position the text on top of the bubble
169
  textposition='middle center',
170
+ # --- THE KEY FIX IS HERE ---
171
+ # Set the text color to white for visibility against dark bubble colors
172
+ textfont=dict(color='white', size=10),
173
+ # ---------------------------
174
  hovertemplate='<b>%{customdata[0]}</b><br>Weight: %{customdata[1]:.3f}<extra></extra>',
175
  marker=dict(line=dict(width=1, color='DarkSlateGrey'))
176
  )