Phase 5: Visualization¶
Module: src/visualize.py
Estimated Time: ~1 day
Objective¶
Generate three complementary interactive HTML visualizations from the knowledge graph.
Visualizations¶
1. Network Graph (network.html)¶
An interactive force-directed graph powered by Pyvis (vis.js):
- Node colors by type:
- π‘ Gold = Laureate
- π΅ Light blue = Work (paper)
- π’ Green = Concept
- π Orange = Award
- π£ Purple = Field
- Edge styles:
- π΄ Red thick lines =
CROSS_INSPIRED(cross-disciplinary migration) - Gray lines = other relationships
- π΄ Red thick lines =
- Interactions:
- Drag nodes to rearrange
- Zoom in/out
- Hover for details
- Click to highlight connections
2. Timeline (timeline.html)¶
A Plotly scatter plot showing concepts distributed across time:
- X-axis: Year (1920β2025)
- Y-axis: Scientific field
- Points: Concepts sized by connection count
- Red arrows: Cross-disciplinary migration events
- Hover: Concept name, year, field, and description
3. Heatmap (heatmap.html)¶
A Plotly heatmap showing cross-field migration intensity:
- Rows: Source fields
- Columns: Target fields
- Color intensity: Number of cross-disciplinary migrations
- Hover: Exact count and field pair
Technical Details¶
Network Graph (Pyvis)¶
net = Network(height="900px", width="100%", directed=True, ...)
net.barnes_hut(gravity=-5000, spring_length=200)
The graph includes an HTML legend overlay showing node type colors.
Timeline (Plotly)¶
fig = go.Figure()
fig.add_trace(go.Scatter(
x=years, y=fields,
mode='markers+text',
marker=dict(size=sizes, color=colors)
))
Annotations are added for each CROSS_INSPIRED edge as arrow lines.
Heatmap (Plotly)¶
Viewing¶
Start a local server:
Open in browser:
- Network:
http://localhost:8765/network.html - Timeline:
http://localhost:8765/timeline.html - Heatmap:
http://localhost:8765/heatmap.html