wilmerags commited on
Commit
6028fe6
·
1 Parent(s): 2c7ffd9

test: Try different approach to legend

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -11,7 +11,7 @@ import numpy as np
11
  import streamlit as st
12
 
13
  from gensim.utils import deaccent
14
- from bokeh.models import ColumnDataSource, HoverTool, Label
15
  from bokeh.palettes import Colorblind as Pallete
16
  from bokeh.palettes import Set3 as AuxPallete
17
  from bokeh.plotting import Figure, figure
@@ -106,10 +106,11 @@ 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
- p.legend.location = "right"
110
- p.legend.title = "Topics ID"
111
- p.legend.click_policy = "mute"
112
- p.legend.background_fill_alpha = 0.2
 
113
 
114
  p.circle("x", "y", size=12, source=source, fill_alpha=0.4, line_color=colors, fill_color=colors, legend_group="original_label")
115
  p.axis.visible = False
@@ -123,6 +124,7 @@ def draw_interactive_scatter_plot(
123
  text_font_size="14px", text_color="gray",
124
  text="Topic equals -1 means no topic was detected for such tweet")
125
  p.add_layout(disclaimer, "below")
 
126
  return p
127
 
128
  # Up to here
 
11
  import streamlit as st
12
 
13
  from gensim.utils import deaccent
14
+ from bokeh.models import ColumnDataSource, HoverTool, Label, Legend
15
  from bokeh.palettes import Colorblind as Pallete
16
  from bokeh.palettes import Set3 as AuxPallete
17
  from bokeh.plotting import Figure, figure
 
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(location = 'right', title='Topics ID', click_policy='mute', background_fill_alpha=0.2)
110
+ # p.legend.location = "right"
111
+ # p.legend.title = "Topics ID"
112
+ # p.legend.click_policy = "mute"
113
+ # p.legend.background_fill_alpha = 0.2
114
 
115
  p.circle("x", "y", size=12, source=source, fill_alpha=0.4, line_color=colors, fill_color=colors, legend_group="original_label")
116
  p.axis.visible = False
 
124
  text_font_size="14px", text_color="gray",
125
  text="Topic equals -1 means no topic was detected for such tweet")
126
  p.add_layout(disclaimer, "below")
127
+ p.add_layout(legend, "right")
128
  return p
129
 
130
  # Up to here