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 response:
counties = json.load(response)
df = pd.DataFrame(data=[feat['properties'].get('NAME_3') for feat in counties['features']],columns=['names'])
df['values'] = 0
fig = px.choropleth(
data_frame=df,
geojson=counties,
color="values",
color_continuous_scale='blues',
locations="names",
featureidkey="properties.NAME_3",
projection="mercator"
)
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
if __name__ == '__main__':
main()