I am trying to add text to the plotly map below, original code modified from https://plotly.com/python/lines-on-mapbox/
import plotly.graph_objects as go
fig = go.Figure(go.Scattermapbox(
mode = "markers",
marker = {'size': 10}))
fig.add_trace(go.Scattermapbox(
mode = "markers",
lon = longlist,
lat = latlist,
marker = {'size': 10}))
fig.update_layout(
margin ={'l':0,'t':0,'b':0,'r':0},
mapbox = {
'style': "stamen-terrain",
'center': {'lon': -20, 'lat': -20},
'zoom': 1})
fig.show()
I have tried to copy the solution provided at Plotly Scattermapbox: Is there a way to include some text above and below the markers?
See my edited code below which includes new text code to retrieve data from magnitudelist and new code for mapbox_access_token
import plotly.graph_objects as go
mapbox_access_token = 'mytoken'
fig = go.Figure(go.Scattermapbox(
mode = "markers",
marker = {'size': 10}))
data = fig.add_trace(go.Scattermapbox(
mode = "markers",
lon = longlist,
lat = latlist,
marker = {'size': 10},
textposition='top right',
textfont=dict(size=16, color='black'),
text = magnitudelist
))
layout = dict(margin=dict(l=0, t=0, r=0, b=0, pad=0),
mapbox=dict(accesstoken=mapbox_access_token,
center=dict(lat=-20, lon=-20),
style='stamen-terrain',
zoom=1))
fig = go.Figure(data=data, layout=layout)
fig.show()
I am trying to get a result more like this
Any suggestions would be appreciated