Blank chorpleth map with Plotly express

I am trying to build a choropleth map in Plotly of Regions in England by ‘NUTS code’ from data supplied by the government at:

My pandas df contains house price data from each region and looks as such:

    NUTS code                      Region name  ...     price
0          UK                   United Kingdom  ...  1268454.0
1         UK0                          England  ...  1093785.0
2         UKC                       North East  ...    41145.0
3        UKC1           Tees Valley and Durham  ...    18154.0
4       UKC11  Hartlepool and Stockton-on-Tees  ...     4457.0

I am following the docs: which has a geojson file with ~3000 features of US states.

The Plotly code is followed from the examples as looks as such:

import as px

fig = px.choropleth_mapbox(df, geojson=spatial['features'], 
                       locations='NUTS code', color='price', 
                       zoom=5, center = {"lat": 51.4816, "lon": 3.1791},
                       labels={'price':'Price (£)'})

fig.update_geos(showcountries=False, showcoastlines=True, showland=False, fitbounds="locations")

However this simply bring ups a blank World Map with no filling or geometry of the UK regions. Does anyone know why this is?


To be recognized by mapbox, your geojson file must have the following definition:

spatial ={'type': 'FeatureCollection',
                   'features': []



mapbox cannot identify the type and does not render the choropleth. To get it pass


to px.choropleth_mapbox.

1 Like

Thanks @empet.

Although this works in a local environment, when on Dash it still does not load any data. Is there a way to clip the mapbox boundary so that it only renders the UK and not the whole world?

I believe this may help.

Unfortunately you cannot clip the boundary on a mapbox map.

1 Like