Spaces:
Sleeping
Sleeping
updated plotly
Browse files
app.py
CHANGED
|
@@ -153,8 +153,8 @@ fig.update_layout(height=1000, width=1000, template="plotly")
|
|
| 153 |
|
| 154 |
# load data ready to plot for local testing
|
| 155 |
germany = pd.read_csv(MAP_PATH)
|
| 156 |
-
germany["lat"] = germany["lat"]
|
| 157 |
-
germany["lon"] = germany["lon"]
|
| 158 |
# germany.drop(columns=["lat", "lon"], inplace=True)
|
| 159 |
|
| 160 |
# # or generate it directly in this script
|
|
@@ -164,15 +164,13 @@ germany["lon"] = germany["lon"].astype(float)
|
|
| 164 |
# germany.to_csv(MAP_PATH_WITH_COORD, index=False)
|
| 165 |
|
| 166 |
# # germany need columns with lat and lon as well as hover data
|
| 167 |
-
fig_map = px.
|
| 168 |
germany,
|
| 169 |
lat="lat",
|
| 170 |
lon="lon",
|
| 171 |
hover_name="ORG",
|
| 172 |
custom_data=["Count"],
|
| 173 |
-
|
| 174 |
-
zoom=5,
|
| 175 |
-
height=700,
|
| 176 |
)
|
| 177 |
# Custom hover template
|
| 178 |
fig_map.update_traces(
|
|
@@ -183,7 +181,23 @@ fig_map.update_traces(
|
|
| 183 |
]
|
| 184 |
)
|
| 185 |
)
|
| 186 |
-
fig_map.update_layout(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
tensors = {}
|
| 189 |
with safe_open("corpus_embeddings.pt", framework="pt", device="cpu") as f:
|
|
|
|
| 153 |
|
| 154 |
# load data ready to plot for local testing
|
| 155 |
germany = pd.read_csv(MAP_PATH)
|
| 156 |
+
germany["lat"] = pd.to_numeric(germany["lat"])
|
| 157 |
+
germany["lon"] = pd.to_numeric(germany["lon"])
|
| 158 |
# germany.drop(columns=["lat", "lon"], inplace=True)
|
| 159 |
|
| 160 |
# # or generate it directly in this script
|
|
|
|
| 164 |
# germany.to_csv(MAP_PATH_WITH_COORD, index=False)
|
| 165 |
|
| 166 |
# # germany need columns with lat and lon as well as hover data
|
| 167 |
+
fig_map = px.scatter_geo(
|
| 168 |
germany,
|
| 169 |
lat="lat",
|
| 170 |
lon="lon",
|
| 171 |
hover_name="ORG",
|
| 172 |
custom_data=["Count"],
|
| 173 |
+
scope="europe",
|
|
|
|
|
|
|
| 174 |
)
|
| 175 |
# Custom hover template
|
| 176 |
fig_map.update_traces(
|
|
|
|
| 181 |
]
|
| 182 |
)
|
| 183 |
)
|
| 184 |
+
fig_map.update_layout(
|
| 185 |
+
geo=dict(
|
| 186 |
+
showland=True,
|
| 187 |
+
landcolor="LightGray",
|
| 188 |
+
showocean=True,
|
| 189 |
+
oceancolor="LightBlue",
|
| 190 |
+
# showcountries=True,
|
| 191 |
+
# countrycolor="Gray",
|
| 192 |
+
showsubunits=True,
|
| 193 |
+
# subunitcolor="Gray",
|
| 194 |
+
fitbounds="locations", # Fit the map bounds to the locations
|
| 195 |
+
lataxis=dict(range=[47, 55]), # Approximate latitude range for Germany
|
| 196 |
+
lonaxis=dict(range=[5, 16]), # Approximate longitude range for Germany
|
| 197 |
+
),
|
| 198 |
+
mapbox_style="carto-positron",
|
| 199 |
+
height=700,
|
| 200 |
+
)
|
| 201 |
|
| 202 |
tensors = {}
|
| 203 |
with safe_open("corpus_embeddings.pt", framework="pt", device="cpu") as f:
|