Plotly Scatter Geo disappear on Streamlit


I have plot an geographic using plotly go.Scattergeo() and it has worked for times. But today I access to the page and the graph disappear without any error, other functions on the same page still working smoothly.

Steps to reproduce

Code snippet:

testFig = go.Figure()
# for idx, row in XNK_area_dataShow.iterrows():
            lon = dataShow['lon'],
            lat = dataShow['lat'],
            text = dataShow['country'],
            customdata = dataShow['value'],
            marker = dict(
                size = dataShow['value'],
                sizemode = 'area',
                color = dataShow['value'],
                colorscale = "aggrnyl",
                cauto = True,
                opacity = 0.8
            hovertemplate = '<b>Country: %{text}</b>' + '<br><b>Value: %{customdata:,}</b>',
            name = traceName,
            showlegend = False,
                    showland=True, landcolor="wheat",
                    showocean=True, oceancolor="powderblue",)
                    margin=dict(t=70, l=20, r=20, b=20),
                    title = dict(text = figTitle, font=dict(size=25)), 
                    autosize = True
st.plotly_chart(testFig, use_container_width = True)

the dataShow is the pd.DataFrame() with columns: lon, lat, country, value. In which my target is to show the value of each country by the circle size (proportion with the country’s value).

Debug info

  • Streamlit version: 1.23.1
  • Python version: 3.10.11
  • Using Conda environment
  • OS version: Window 11 + WSL2
  • Browser version: Chrome Version 114.0.5735.134

From your description, it appears that the geographical plot generated using go.Scattergeo() from Plotly is not visible when you access the page. Other functions on the same page continue to work smoothly. Here are a few suggestions to help you debug the issue:

  1. Check for errors: Ensure that there are no error messages displayed in the console or terminal where you are running your Streamlit app. If there are any errors related to the plot, they might provide useful information for troubleshooting.

  2. Verify data availability: Double-check that the dataShow DataFrame contains the necessary data for the geographical plot. Confirm that the DataFrame has non-null values for the 'lon', 'lat', 'country', and 'value' columns. You can print the DataFrame or use Streamlit’s st.dataframe() function to inspect the data.

  3. Inspect plot settings: Review the plot settings and ensure that they are appropriate for your data. For example, confirm that the marker size ('size') and color ('color') are being set correctly based on the 'value' column. Verify that the colorscale ('colorscale') is valid and suitable for your data.

  4. Check layout and sizing: Make sure that the plot’s layout settings are appropriate. Confirm that the margin, title, and autosize settings are configured correctly. Consider adjusting these settings or removing them temporarily to check if they are causing any issues.

  5. Test with sample data: Create a minimal working example using a small sample dataset to isolate the issue. This can help identify whether the problem lies in the data or in the specific plot settings.

  6. Update Plotly and Streamlit versions: Ensure that you are using the latest versions of Plotly and Streamlit. Consider updating them to see if the issue has been resolved in a newer release.

  7. Clear browser cache: Clearing the cache of your browser can sometimes resolve visualization issues. Try clearing the cache and reloading the Streamlit app to see if the plot appears.

  8. Test in different browsers: Try accessing your Streamlit app in different browsers to see if the issue is specific to a particular browser. This can help identify any browser-specific compatibility issues.

If the issue persists, providing more details such as any error messages, the specific data being used, and any changes you may have made recently can assist in further troubleshooting.

even I do not try to do anything, the geo-graph appear today for no reason.