streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

plotly_chart is not working with Plotly new standard tile maps (MapLibre)

Open luca-ferreri opened this issue 2 years ago • 12 comments

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

Open in Streamlit Cloud

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: image

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

luca-ferreri avatar Sep 23 '24 13:09 luca-ferreri

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.

Visits

github-actions[bot] avatar Sep 23 '24 13:09 github-actions[bot]

Hi @luca-ferreri thanks for filing this issue. We'll try to get this fixed as soon as we can.

sfc-gh-nbellante avatar Sep 23 '24 16:09 sfc-gh-nbellante

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

msquaredds avatar Oct 04 '24 15:10 msquaredds

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!

adamkgoldfarb avatar Oct 07 '24 23:10 adamkgoldfarb

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.

adamkgoldfarb avatar Nov 20 '24 19:11 adamkgoldfarb

@sfc-gh-nbellante Any update on this issue? I am also facing this problem. Any workaround...

ramakrse avatar Nov 28 '24 04:11 ramakrse

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.

ahoward-ch avatar Jan 21 '25 12:01 ahoward-ch

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!

ndrezn avatar Jan 21 '25 21:01 ndrezn

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.

ndrezn avatar Jan 21 '25 21:01 ndrezn

Confirmed working now! Who knew. Thanks @ndrezn !

adamkgoldfarb avatar Jan 21 '25 21:01 adamkgoldfarb

@sfc-gh-nbellante I think it's safe to close this ticket 👍

ndrezn avatar Jan 22 '25 19:01 ndrezn

confirmed, solved with new version of plotly (tested with plotly.py = 6.0.0). Thanks to all.

luca-ferreri avatar Jan 29 '25 14:01 luca-ferreri