Hello!
I’m trying to repeat the result from SAS via plotly.
Is it possible to make the first screen looks like the second one?
I mean that I want to write data permanently on the map, not only on mouse hover
hi @iamkosyak
Welcome to the community.
Yes, that is possible in Plotly. We have more about this in the text and annotations chapter.
Yeah, I saw this way, but have some problems.
It works fine when I’m adding it to the empty Figure object, but it doesn’t work on the top of plotly.express.choropleth_mapbox (example’s below).
I want to use plotly.express.choropleth_mapbox because it’s the only way to have color_discrete_map I find. Any ideas what am I doing wrong?
So this works::
fig = go.Figure()
fig.add_scattergeo(
lat=[0],
lon=[0],
mode='text',
textfont=dict(
color="black",
size=50,
),
text='123'
)
And this doesn’t work (I see only coloured map):
fig = px.choropleth_mapbox(gdf,
geojson=gdf.geometry,
locations=gdf.index,
color_discrete_map=color_discrete_map,
color=gdf.desc,
mapbox_style="open-street-map",
zoom=1)
fig.add_scattergeo(
lat=[0],
lon=[0],
mode='text',
textfont=dict(
color="black",
size=50,
),
text='123'
)
Works fine with mapbox_style=“basic”, but not with mapbox_style=“open-street-map”