Dude Skywalk
Dude Skywalk

Reputation: 63

Plotly express or Go - Labels inside Counties for a map

I am trying to put a label on tiles based on a “CHANGE” or “COUNTY” item as shown below. I couldnt achieve it. Below is my sample code.

fig = px.choropleth(stat_data, geojson=geo_json_data, color="CHANGE",
                    locations="COUNTY", featureidkey="properties.COUNTY",
                    projection="mercator",
                    color_continuous_scale=px.colors.diverging.RdYlGn, color_continuous_midpoint=2
                          )

fig.update_geos(fitbounds="locations", visible=False)
fig.show()

I tried with plotlyexpress or go method with the advice shown on answer on other forum looks like it only works for figure factory since scatter method is only available for that one.

Any help will be appreciated.

enter image description here

Upvotes: 2

Views: 897

Answers (1)

Dude Skywalk
Dude Skywalk

Reputation: 63

I found an answer on here : https://community.plotly.com/t/annotations-on-plotly-choropleth/36219

fig.add_scattergeo(
  geojson=counties,
  locations = df['names'],
  text = df['values'],
  featureidkey="properties.NAME_3",
  mode = 'text') 

Upvotes: 2

Related Questions