wilmerags commited on
Commit
ce50e18
·
1 Parent(s): 60bdc33

fix: Improve legend placement with new approach

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -106,7 +106,7 @@ def draw_interactive_scatter_plot(
106
  p = figure(plot_width=800, plot_height=800, tools=[hover], title='2D visualization of tweets', background_fill_color="#fafafa")
107
  colors = factor_cmap("label", palette=[Pallete[n_colors][int(id_) + 1] for id_ in values_set], factors=values_set)
108
 
109
- # legend = Legend(source=source, legend_group='original_label', title='Topics ID', click_policy='mute', background_fill_alpha=0.2)
110
  p.circle("x", "y", size=12, source=source, fill_alpha=0.4, line_color=colors, fill_color=colors, legend_group="original_label")
111
  p.axis.visible = False
112
  p.xgrid.grid_line_dash = "dashed"
@@ -115,9 +115,9 @@ def draw_interactive_scatter_plot(
115
  # p.ygrid.grid_line_color = None
116
  p.toolbar.logo = None
117
 
118
- p.legend.location = "bottom_right"
119
- p.legend.title = "Topics ID"
120
- p.legend.background_fill_alpha = 0.25
121
 
122
  disclaimer = Label(x=0, y=0, x_units="screen", y_units="screen",
123
  text_font_size="14px", text_color="gray",
@@ -146,7 +146,7 @@ def generate_plot(
146
  with st.spinner("Now trying to express them with my own words... 💬"):
147
  for label in set(encoded_labels):
148
  if label == -1:
149
- cluster_keyword[label] = '-1'
150
  continue
151
  cluster_keyword[label] = []
152
  cluster_tws = []
 
106
  p = figure(plot_width=800, plot_height=800, tools=[hover], title='2D visualization of tweets', background_fill_color="#fafafa")
107
  colors = factor_cmap("label", palette=[Pallete[n_colors][int(id_) + 1] for id_ in values_set], factors=values_set)
108
 
109
+ p.add_layout(Legend(title='Topics keywords', background_fill_alpha=0.2), 'right')
110
  p.circle("x", "y", size=12, source=source, fill_alpha=0.4, line_color=colors, fill_color=colors, legend_group="original_label")
111
  p.axis.visible = False
112
  p.xgrid.grid_line_dash = "dashed"
 
115
  # p.ygrid.grid_line_color = None
116
  p.toolbar.logo = None
117
 
118
+ # p.legend.location = "bottom_right"
119
+ # p.legend.title = "Topics ID"
120
+ # p.legend.background_fill_alpha = 0.25
121
 
122
  disclaimer = Label(x=0, y=0, x_units="screen", y_units="screen",
123
  text_font_size="14px", text_color="gray",
 
146
  with st.spinner("Now trying to express them with my own words... 💬"):
147
  for label in set(encoded_labels):
148
  if label == -1:
149
+ cluster_keyword[label] = 'Too diverse!'
150
  continue
151
  cluster_keyword[label] = []
152
  cluster_tws = []