I recently started playing around with the plotly.express library for making choropleth maps. I've been able to create one just fine using a GeoJSON of a state's census tracts and a Pandas dataframe, however, I'd like to add another "layer" on top of the census tracts to show where municipal boundaries are (I have a GeoJSON for this as well). I haven't been able to find a walkthrough/guide where someone does something like this, and I haven't been able to figure out much from the plotly documentation.

Here's my code for the main choropleth plot:

fig = px.choropleth(
    geojson= Tracts,
    locations= df['TRACTCE10'],
    color= df['someVariable'],
    featureidkey= 'properties.tractce10',

fig.update_geos(fitbounds="locations", visible=True)

Any advice or links to a possible solution?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.