💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

Paper background and centering title for Choropleth map with geojson and pandas/geopands in python and Jupyter notebook

Hi all,
I am creating a Choropleth map using geojson. All works fine except the paper background. All is fine except for two issues:

  1. I cannot remove the grey/blue-ish background despite using paper_bgcolor='rgba(0,0,0,0)'.
  2. Somehow I cannot properly center the title over the map. Is there a way to center it over the map minus the scale?

Currently using: pandas and geopandas, python3.6, Jupyter notebook

Below are code and image.

Any pointers are appreciated. Many thanks!

title = 'Colorado county data on a map'

mapping = go.Choropleth(geojson=co_geo,
                        locationmode='geojson-id',
                        featureidkey='properties.GEOID',
                        locations=county_month['GEOID'][mask1],
                        z=county_month['datacount'][mask1],
                        text=county_month['county'][mask1],
                        hoverinfo='text+z',
                        zmin=1,
                        zmax=county_month['datacount'][mask1].max(),
                        colorscale='Sunsetdark')

mapping2 = go.Choropleth(geojson=co_geo,
                         locationmode='geojson-id',
                         featureidkey='properties.GEOID',
                         locations=county_month[mask2]['GEOID'],
                         z=county_month['datacount'][mask2],
                         text=county_month['county'][mask2],
                         hoverinfo='text+z',
                         colorscale='Greys',
                         zmin=0,
                         zmax=100,
                         showscale=False)

data = [mapping, mapping2]
layout=go.Layout(title=title,
                 font={'size':18,
                       'color':'#7f7f7f',
                       'family':'Courier New, monospace'})
fig = go.Figure(data=data, layout=layout)
fig.update_geos(projection_type='mercator',
               fitbounds='locations')
fig.update_layout(title={
    'x':0.4,
    'xanchor':'center'
})
fig.update_layout(margin={'r':0, 't':50, 'l':0, 'b':0, 'pad':0},
                  paper_bgcolor='rgba(0,0,0,0)',
                  plot_bgcolor='rgba(0,0,0,0)')
pyo.plot(fig,filename=filename)

This is how it looks like.