This is the sample code from plotly choropleth figure.
The figure is displayed fine with fig.show()
, but broken in a st app.
It works fine with other type of plotly figure, but seems that no data is attached in a choropleth figure.
Any help is appreciated.
Here is the code:
import streamlit as st
import plotly.express as px
df = px.data.election()
geojson = px.data.election_geojson()
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})
st.plotly_chart(fig)
Expected figure:
Displayed in st: