22
33import numpy as np
44import pandas as pd
5- from bokeh .models import ColumnDataSource , HoverTool , Range1d , WheelZoomTool , Label
5+ from bokeh .models import ColumnDataSource , HoverTool , Range1d , WheelZoomTool
6+ from bokeh .models .annotations import Label
67from bokeh .plotting import figure
78
89from . import resources as rsc
@@ -233,24 +234,26 @@ def get_bokeh(df, linear=False):
233234 X = 0
234235 Y = 0
235236
236- TOOLTIPS = '<div style="max-width: 600px">< font size="3"><b>@Feature</b> — @Type @pi_permatch_int</font> <br> @Description</div> '
237+ TOOLTIPS = '<font size="3"><b>@Feature</b> — @Type @pi_permatch_int</font> <br> @Description'
237238
238- hover = HoverTool (tooltips = TOOLTIPS )
239+ hover = HoverTool (names = [ "features" ] )
239240 PLOT_SIZE = 0.35
240241 PLOT_DIMENSIONS = 800
241242
242243 x_range = Range1d (- PLOT_SIZE , PLOT_SIZE , bounds = (- 0.5 , 0.5 ), min_interval = 0.1 )
243244 y_range = Range1d (- PLOT_SIZE , PLOT_SIZE , bounds = (- 0.5 , 0.5 ), min_interval = 0.1 )
244245
245246 p = figure (
246- height = PLOT_DIMENSIONS ,
247- width = PLOT_DIMENSIONS ,
247+ plot_height = PLOT_DIMENSIONS ,
248+ plot_width = PLOT_DIMENSIONS ,
248249 title = "" ,
249250 toolbar_location = None ,
250251 toolbar_sticky = False ,
251- aspect_ratio = 1 ,
252+ match_aspect = True ,
252253 sizing_mode = "scale_width" ,
253254 tools = ["save" , hover , "pan" ],
255+ tooltips = TOOLTIPS ,
256+ # x_range=(-plotSize, plotSize), y_range=(-plotSize, plotSize))
254257 x_range = x_range ,
255258 y_range = y_range ,
256259 )
@@ -337,7 +340,7 @@ def get_bokeh(df, linear=False):
337340 orient ["has_orientation" ] = orient ["has_orientation" ].map ({"T" : True })
338341 df = df .merge (orient , on = "Type" , how = "left" )
339342 df ["Type" ] = df ["Type" ].str .replace ("_" , " " )
340- df ["has_orientation" ] = df ["has_orientation" ].astype ( bool ). fillna (value = False )
343+ df ["has_orientation" ] = df ["has_orientation" ].fillna (value = False ). infer_objects ( )
341344
342345 df [
343346 [
@@ -361,7 +364,7 @@ def get_bokeh(df, linear=False):
361364
362365 # plot annotations
363366 source = ColumnDataSource (df )
364- feature_renderer = p .patches (
367+ p .patches (
365368 "x" ,
366369 "y" ,
367370 fill_color = "fill_color" ,
@@ -371,7 +374,6 @@ def get_bokeh(df, linear=False):
371374 source = source ,
372375 legend_group = "legend" ,
373376 )
374- hover .renderers = [feature_renderer ]
375377 p .multi_line (
376378 xs = "lineX" ,
377379 ys = "lineY" ,
@@ -525,6 +527,6 @@ def get_bokeh(df, linear=False):
525527 # legend location
526528 p .legend .location = "bottom_left"
527529 p .legend .border_line_color = "#EFEFEF"
528- p .legend .click_policy = "hide"
530+ p .legend .visible = True
529531
530532 return p
0 commit comments