Я пытался создать интерактивный график по респондентам и категориям ответов для исследования интервью с Bokeh, но я не могу заставить метки появляться при наведении курсора на узлы. Я пытался использовать решения из Добавление меток узлов к сетевым графикам bokeh , но я продолжаю сталкиваться с теми же проблемами, что Kristada673 описывает в комментариях.
Есть идеи?
from bokeh.io import show, output_file
from bokeh.models import Plot, Range1d, MultiLine, Circle, HoverTool, TapTool, BoxSelectTool
from bokeh.models.graphs import from_networkx, NodesAndLinkedEdges, EdgesAndLinkedNodes
from bokeh.palettes import Spectral4
G=nx.Graph()
respondent = ["TI01", "TI02", "TI03", "TT01", "TT02", "TT03"] #Respondents
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
code=["Previous Teaching", "Avoidance Strategies", "Spelling by Sound", "Homophones", "Individual Oral Feedback", "Written Feedback", "Articles", "Overwhelmed Students", "Verb Tenses", "Punctuation", "Formal Register", "Run-on Sentences", "Matrices/Rubrics", "Peer-review", "Sentence Structures"] #Substantive Codes
G.add_nodes_from(respondent)
G.add_nodes_from(code)
#First Pilot
#TI01
G.add_edges_from([("TI01", code[0]), ("TI01", code[2]), ("TI01", code[5])])
#TI02
G.add_edges_from([("TI02", code[2]), ("TI02", code[3]), ("TI02", code[0]), ("TI02", code[4]), ("TI02", code[5])])
#TI03
G.add_edges_from([("TI03", code[0]), ("TI03", code[1]),("TI03", code[5])])
#Second Pilot
#TT01
G.add_edges_from([("TT01", code[2]), ("TT01", code[3]), ("TT01", code[4]), ("TT01", code[5])])
#TT02
G.add_edges_from([("TT02", code[6]), ("TT02", code[9]), ("TT02", code[8]), ("TT02", code[10]), ("TT02", code[0]), ("TT02", code[13])])
#TT03
G.add_edges_from([("TT03", code[14]), ("TT03", code[0]),("TT03", code[13]), ("TT03", code[12]), ("TT03", code[9]), ("TT03", code[11])])
plot = Plot(plot_width=600, plot_height=600,
x_range=Range1d(-1.1,1.1), y_range=Range1d(-1.1,1.1))
plot.title.text = "Possible Substantive Codes Pilot Interviews"
hover = HoverTool(tooltips=[('respondent','code')])
plot.add_tools(hover, TapTool())
graph_renderer = from_networkx(G, nx.circular_layout, scale=1, center=(0,0))
graph_renderer.node_renderer.glyph = Circle(size=20, fill_color=Spectral4[0])
graph_renderer.node_renderer.selection_glyph = Circle(size=15, fill_color=Spectral4[2])
graph_renderer.node_renderer.hover_glyph = Circle(size=15, fill_color=Spectral4[1])
graph_renderer.edge_renderer.glyph = MultiLine(line_color="#CCCCCC", line_alpha=0.8, line_width=5)
graph_renderer.edge_renderer.selection_glyph = MultiLine(line_color=Spectral4[2], line_width=5)
graph_renderer.edge_renderer.hover_glyph = MultiLine(line_color=Spectral4[1], line_width=5)
graph_renderer.selection_policy = NodesAndLinkedEdges()
graph_renderer.inspection_policy = NodesAndLinkedEdges()
plot.renderers.append(graph_renderer)
output_file("interactive_graphs.html")
show(plot)