Plotly choropleth map won't show in dash app

Hi,

I’m experiencing an issue where the plolty px choropleth maps don’t show up in dash apps. All that is visible is the color bar scale.

I can save the plots to a html file and they appear as expected. E.g.

Here’s a simple code example:

import plotly.express as px
from dash import Dash, dcc, html


#data for choropleth
df = px.data.election()
geojson = px.data.election_geojson()

#create choropleth plot
fig = px.choropleth(df, geojson=geojson, color="Bergeron",
                    locations="district", featureidkey="properties.district",
                    projection="mercator"
                   )
fig.update_geos(fitbounds="locations", visible=False)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.write_html("choropleth_map.html")

#create dash app
PORT = "9000"
ADDRESS = "0.0.0.0"

app = Dash(__name__, suppress_callback_exceptions=True)

app.layout = html.Div([
    dcc.Graph(
            id="choropleth",
            figure = fig,
        ),
])

if __name__ == "__main__":
    app.run_server(debug=True, port=PORT, host=ADDRESS)

I’m using the latest versions of dash/plotly (dash==2.5.1 and plotly == 5.9.0)

Things I’ve tried:

  • Creating the same plot using ploty graph objects.
  • Using old versions of dash/ploty (e.g. dash==2.4.0 and plotly==5.8.0)

I’ve found an old forum thread where users have the same issue, in their case it was solved by using older versions of plotly/dash but I’m yet to find any combination that fixes the issue for me:

Hi @sean54123

I ran your code example and it worked. Try adding this to your code to make sure it’s actually running the latest version:

import dash
print(dash.__version__)

Thank you for your response.

I’ve checked and I’m definitely running the latest version. I’ve verified that other people in my team can’t get the code to work regardless of the package versions so I’m assuming it’s an issue with our I.T. setup (and not and issue with Dash!)