# How to add static labels to plotly express \`choropleth\_mapbox\`?

**URL:** <https://community.plotly.com/t/how-to-add-static-labels-to-plotly-express-choropleth-mapbox/53911>\
**Category:** 📊 Plotly Python\
**Created:** [June 15, 2021, 3:56pm UTC](https://community.plotly.com/t/how-to-add-static-labels-to-plotly-express-choropleth-mapbox/53911 "2021-06-15T15:56:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karolzlot](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@karolzlot](https://community.plotly.com/u/karolzlot)\
**Post date:** [June 15, 2021, 3:56pm UTC](https://community.plotly.com/t/how-to-add-static-labels-to-plotly-express-choropleth-mapbox/53911/1 "2021-06-15T15:56:28Z")

</div>

With current code I get hover tooltips, however those are not visible on PNG export. I need to have static label on each polygon.

[![plotly choropleth_mapbox](https://i.stack.imgur.com/gSVdM.png)](https://i.stack.imgur.com/gSVdM.png)

```auto
import plotly.express as px

df = px.data.election()
geojson = px.data.election_geojson()

fig = px.choropleth_mapbox(df, geojson=geojson, color="Bergeron",
                           locations="district", featureidkey="properties.district",
                           center={"lat": 45.5517, "lon": -73.7073},
                           mapbox_style="carto-positron", zoom=9)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

```

Solutions which I found are not working, they work only for `choropleth` but not for `choropleth_mapbox` which I want to use. List of them:

> [@Labels inside Counties for a map](https://community.plotly.com/t/labels-inside-counties-for-a-map/13953):
>
> Hello, Kind of a newbie question but I have not been able to find the proper answer. Instead of having the hover label, I was trying to find a way to show labels in each county Polygon. I have the following code: init\_notebook\_mode() data=pd.read\_excel(‘AZ Sales by FIPS.xlsx’, dtype={‘FIPS’:object}) df\_sample\_r = data[data[‘State’] == ‘AZ’] values = df\_sample\_r[‘Sales’].tolist() fips = df\_sample\_r[‘FIPS’].tolist() colorscale = [ ‘rgb(193, 193, 193)’, ‘rgb(239,239,239)’, ‘rgb(195, 196…

> [@Annotations on plotly Choropleth](https://community.plotly.com/t/annotations-on-plotly-choropleth/36219):
>
> I am trying to add static labels to a choropleth chart. However, I did not find any information as to how to do that. I would like to display the values (right now all 0 obviously) number statically on the map. I am currently building my chart like this: import plotly.express as px import pandas as pd import json from urllib.request import urlopen def main(): URL = "https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/master/4\_kreise/4\_niedrig.geojson" with urlopen(URL) as …

> [@How can I change the hover labels into static labels?](https://community.plotly.com/t/how-can-i-change-the-hover-labels-into-static-labels/4690/2):
>
> Hey @wangyp1937, you can add an additional scattergeo trace like such: trace2 = go.Scattergeo( locations = df['code'], locationmode = 'USA-states', text = df['code'], mode = 'text') data = [trace1,trace2]

---

<div class="post-metadata">

**Author:** ![karolzlot](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@karolzlot](https://community.plotly.com/u/karolzlot)\
**Post date:** [June 18, 2021, 3:28pm UTC](https://community.plotly.com/t/how-to-add-static-labels-to-plotly-express-choropleth-mapbox/53911/2 "2021-06-18T15:28:32Z")

</div>

Solution on Stack Overflow:

> <https://stackoverflow.com/questions/67989327/how-to-add-static-labels-to-plotly-express-choropleth-mapbox>
