plotly_chart is not working with Plotly new standard tile maps (MapLibre)
Checklist
- [X] I have searched the existing issues for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.
Summary
Plotly has recently announced their transition in managing tile maps, specifically switching from Mapbox to MapLibre.
The switch for Plotly users should be smooth: simply replace the tracenames from _mapbox to _map.
Unfortunately, this transition has some impact on Streamlit.
Reproducible Code Example
import streamlit as st
import plotly.graph_objects as go
import plotly.express as px
st.title("Some Title")
# example from https://plotly.com/python/tile-scatter-maps/#basic-example-with-plotly-express
df = px.data.carshare()
fig = px.scatter_map(
df,
lat="centroid_lat",
lon="centroid_lon",
color="peak_hour",
size="car_hours",
color_continuous_scale=px.colors.cyclical.IceFire,
size_max=15,
zoom=10,
)
st.plotly_chart(fig, use_container_width=True)
Steps To Reproduce
No response
Expected Behavior
A map centered on Montreal should be shown as Streamlit component (as visible here).
Current Behavior
Instead a blank Cartesian coordinate system is shown:
Is this a regression?
- [ ] Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.38.0
- Python version: 3.12
- Operating System: Linux Debian 12 (Bookworm); also on Windows 11 Enterprise
- Browser: Chrome and Edge
Additional Information
No response
If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.
Your feedback helps us prioritize which bugs to investigate and address first.
Hi @luca-ferreri thanks for filing this issue. We'll try to get this fixed as soon as we can.
I'm seeing the same type of issue with plotly_chart. I haven't been able to consistently reproduce it, as 1. some of the charts in my app work and some just show the blank Cartesian coordinate system and 2. sometimes all the charts work and sometimes a few charts don't work - I'm hosting on AWS and if I reboot the machine it will sometimes fix the issue, although not consistently
I am seeing OP's issue as well. It will be nice to not have to fiddle with mapbox tokens for some maps, and apparently there will be processing improvements attributable to improved rendering and WebGL2 support per the migration guide. Thanks to the team for looking into this!
Hi All, just checking in here-- if there's some code I can track/contribute to, happy to see about a patch. May be over my head but worth a shot.
@sfc-gh-nbellante Any update on this issue? I am also facing this problem. Any workaround...
Can confirm, this issues still persists as of Jan 2025. With my org using streamlit from within Snowflake, and Snowflake's Folium install and streamlit plugin being seemingly broken, we require the improvements mapLibre offers over mapbox.
Hey folks, Plotly TPM for OSS Libraries here. Streamlit team, if you think this issue would be better fixed upstream, let us know. It's not clear to me whether this bug comes from Plotly or is specific to st.plotly_chart. Thanks!
Actually, when I check the example linked (https://issues.streamlit.app/?issue=gh-9517) it looks like it works as expected. Maybe this was resolved in a more recent patch release of Plotly, from Plotly.js 2.35.1 or 2.35.2? There were a few fixes for MapLibre charts in those releases. Plotly users ITT might consider updating Plotly.py to >=5.24.1.
Confirmed working now! Who knew. Thanks @ndrezn !
@sfc-gh-nbellante I think it's safe to close this ticket 👍
confirmed, solved with new version of plotly (tested with plotly.py = 6.0.0). Thanks to all.