baconnier commited on
Commit
82d9c75
·
verified ·
1 Parent(s): 5962924

Create visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +69 -0
visualization.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import plotly.graph_objects as go
2
+ from typing import List, Dict, Any
3
+
4
+ def create_map_visualization(locations: List[Dict[str, Any]]) -> go.Figure:
5
+ fig = go.Figure()
6
+
7
+ # Add markers for each location
8
+ fig.add_trace(go.Scattergeo(
9
+ lon=[loc["longitude"] for loc in locations],
10
+ lat=[loc["latitude"] for loc in locations],
11
+ text=[loc["place_name"] for loc in locations],
12
+ mode="markers+text",
13
+ marker=dict(size=10, color="red"),
14
+ textposition="top center"
15
+ ))
16
+
17
+ # Update layout
18
+ fig.update_layout(
19
+ geo=dict(
20
+ scope="world",
21
+ showland=True,
22
+ showcountries=True,
23
+ landcolor="rgb(243, 243, 243)",
24
+ countrycolor="rgb(204, 204, 204)"
25
+ ),
26
+ title="Historical Art Locations",
27
+ height=600
28
+ )
29
+
30
+ return fig
31
+
32
+ def create_timeline_visualization(timeline_data: Dict[str, Any]) -> go.Figure:
33
+ fig = go.Figure()
34
+
35
+ # Add period span
36
+ fig.add_trace(go.Scatter(
37
+ x=[timeline_data["start_year"], timeline_data["end_year"]],
38
+ y=[1, 1],
39
+ mode="lines+markers",
40
+ name=timeline_data["period_name"],
41
+ line=dict(width=20, color="rgb(100, 100, 200)")
42
+ ))
43
+
44
+ # Add historical events
45
+ event_years = list(range(
46
+ timeline_data["start_year"],
47
+ timeline_data["end_year"],
48
+ (timeline_data["end_year"] - timeline_data["start_year"]) // len(timeline_data["events"])
49
+ ))
50
+
51
+ fig.add_trace(go.Scatter(
52
+ x=event_years[:len(timeline_data["events"])],
53
+ y=[1.2] * len(timeline_data["events"]),
54
+ mode="markers+text",
55
+ text=timeline_data["events"],
56
+ textposition="top center",
57
+ marker=dict(size=8, color="red")
58
+ ))
59
+
60
+ # Update layout
61
+ fig.update_layout(
62
+ title="Historical Timeline",
63
+ showlegend=False,
64
+ height=400,
65
+ yaxis=dict(visible=False),
66
+ xaxis=dict(title="Year")
67
+ )
68
+
69
+ return fig