import plotly
import plotly.express as px
import plotly.graph_objects as go
## mapbox_token can be obtained free on mapbox website
mapbox_access_token = open(".mapbox_token").read()
color_huangpu = 'rgba(0, 191, 255, 0.6)'
fig = go.Figure(go.Scattermapbox())
## Plot trace / scatter
fig = go.Figure(go.Scattermapbox(
mode = "lines", # or "markers"
fill = "toself",
lon = huangpu_lon_ls,
lat = huangpu_lat_ls,
text = text_ls,
marker = { 'size': 10, 'color': color_huangpu }))
## Add trace / scatter
fig.add_trace(go.Scattermapbox(
mode = "lines", # or "markers"
fill = "toself",
lon = xuhui_lon_ls,
lat = xuhui_lat_ls,
text = text_ls,
marker = { 'size': 10, 'color': color_xuhui }))
## Customize layout
fig.update_layout(mapbox_style="open-street-map", mapbox_zoom=10,
mapbox_center_lat = 31.22,
mapbox_center_lon = 121.44,
margin={"r":0,"t":0,"l":0,"b":0},)
fig.update_layout(mapbox_style="light", mapbox_accesstoken=mapbox_access_token,showlegend=False,)
# Save figure
figure_name = "shanghai_map.html"
plotly.offline.plot(fig, filename=os.path.join(figure_path,figure_name))