Skip to content

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
  • 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)

fig = go.Figure(data=go.Heatmap(
    z=matrix, x=fields, y=fields,
    colorscale='YlOrRd'
))

Viewing

Start a local server:

python3 -m http.server 8765 --directory output/viz

Open in browser:

  • Network: http://localhost:8765/network.html
  • Timeline: http://localhost:8765/timeline.html
  • Heatmap: http://localhost:8765/heatmap.html

Running

# Via pipeline
uv run python main.py --phase 5

# Standalone
uv run python -m src.visualize