jfataphd commited on
Commit
2da59f7
·
1 Parent(s): 40d4151

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -258,17 +258,19 @@ if query:
258
  # Add circles for the top 50 similar words
259
  fig.add_trace(go.Scatter(x=X_top[:, 0], y=X_top[:, 1], mode='markers',
260
  marker=dict(size=2, color=sims_query_top, colorscale='RdYlGn', symbol='circle'),
261
- text=words, customdata=sims, name='', z=1))
262
 
263
- # Represent query as a large red diamond
264
  fig.add_trace(go.Scatter(x=[model.wv[query][0]], y=[model.wv[query][1]], mode='markers',
265
  marker=dict(size=12, color='black', symbol='diamond'), name=query, hovertext=query,
266
- showlegend=False, z=2))
267
 
268
- # Add label for the query above the diamond
269
  fig.add_trace(go.Scatter(x=[model.wv[query][0]], y=[model.wv[query][1]], mode='text', text=[query],
270
  textposition='top right', textfont=dict(color='blue', size=10), hoverinfo='none',
271
- showlegend=False, z=3))
 
 
 
272
 
273
  fig.update(layout_coloraxis_showscale=True)
274
  fig.update_layout(autosize=True, paper_bgcolor="#CCFFFF", margin=dict(t=0, b=0, l=0, r=0))
@@ -276,6 +278,7 @@ if query:
276
 
277
  st.plotly_chart(fig, use_container_width=True)
278
 
 
279
  st.markdown(
280
  f"<b><p style='font-family: Arial; font-size: 20px; font-style: Bold;'>Top <span style='color:red; font-style: italic;'>{value_word} "
281
  f"</span>words contextually and semantically similar to "
 
258
  # Add circles for the top 50 similar words
259
  fig.add_trace(go.Scatter(x=X_top[:, 0], y=X_top[:, 1], mode='markers',
260
  marker=dict(size=2, color=sims_query_top, colorscale='RdYlGn', symbol='circle'),
261
+ text=words, customdata=sims, name=''))
262
 
263
+ # Represent query as a large red diamond and label
264
  fig.add_trace(go.Scatter(x=[model.wv[query][0]], y=[model.wv[query][1]], mode='markers',
265
  marker=dict(size=12, color='black', symbol='diamond'), name=query, hovertext=query,
266
+ showlegend=False))
267
 
 
268
  fig.add_trace(go.Scatter(x=[model.wv[query][0]], y=[model.wv[query][1]], mode='text', text=[query],
269
  textposition='top right', textfont=dict(color='blue', size=10), hoverinfo='none',
270
+ showlegend=False))
271
+
272
+ # Set the order of the traces
273
+ fig.update_layout(legend=dict(traceorder='reversed'), showlegend=True)
274
 
275
  fig.update(layout_coloraxis_showscale=True)
276
  fig.update_layout(autosize=True, paper_bgcolor="#CCFFFF", margin=dict(t=0, b=0, l=0, r=0))
 
278
 
279
  st.plotly_chart(fig, use_container_width=True)
280
 
281
+
282
  st.markdown(
283
  f"<b><p style='font-family: Arial; font-size: 20px; font-style: Bold;'>Top <span style='color:red; font-style: italic;'>{value_word} "
284
  f"</span>words contextually and semantically similar to "