plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

Mapbox stamen styles not working

Open shawnrosofsky opened this issue 1 year ago • 1 comments

It appears that the stamen styles (stamen-terrain, stamen-toner, stamen-watercolor) no longer work on mapbox maps. Using one of these styles, just gives a blank map under the data provided to the plotting function. I could provide an example of trying this myself, but it appears that the example pages using this style also have this problem such as https://plotly.com/python/mapbox-density-heatmaps/.

Is this a bug or is there some issue with mapbox no longer supporting stamen styles?

shawnrosofsky avatar Nov 15 '23 22:11 shawnrosofsky

Stamen switched to a paid model under Stadia Maps. This is addressed in plotly.js v2.27.1 which we will incorporate in a new plotly.py release shortly.

alexcjohnson avatar Nov 15 '23 22:11 alexcjohnson

This was included in the latest Plotly.py release, 5.19. The docs show examples of using a token for the stamen styles https://plotly.com/python/mapbox-density-heatmaps/#stamen-terrain-base-map-stadia-maps-token-needed-density-mapbox-with-plotlyexpress

LiamConnors avatar Feb 28 '24 15:02 LiamConnors

I made my token, cut-and-pasted the example from the link Liam provided above into a Jupyter notebook, and it still doesn't work. The data is plotting fine but the background is missing.

rmthomps avatar Mar 22 '24 19:03 rmthomps

I made my token, cut-and-pasted the example from the link Liam provided above into a Jupyter notebook, and it still doesn't work. The data is plotting fine but the background is missing.

I'm experiencing the same issue. The data gets plotted but the map background is empty. I'm using Plotly 5.20.0

tuopouk avatar Mar 24 '24 20:03 tuopouk

This actually works for me @tuopouk @rmthomps .

I used my own mapbox token in this code and I got the background to display fine. I'm using Plotly 5.20.0 and the Firefox browser.

import plotly.graph_objects as go
import pandas as pd

token = 'my-token'

quakes = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

fig = go.Figure(go.Densitymapbox(lat=quakes.Latitude, lon=quakes.Longitude, z=quakes.Magnitude,
                                 radius=10))
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180, mapbox_accesstoken=token)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

Coding-with-Adam avatar Mar 27 '24 14:03 Coding-with-Adam

For me with that exact code this kind of map gets generated. The result is the same whether it's a mapbox token or a stadia token.

image

I also tried other stamen types (stamen-watercolor and stamen-toner) but with the same result as above. I tried the rendering in VS Code and exported it to html to open it with Firefox but the background seems to be lacking still. @Coding-with-Adam Did you get the map background rendered.

For instance the open-street-map renders correctly with both tokens image

tuopouk avatar Mar 27 '24 17:03 tuopouk

hi @tuopouk I'm not sure what's the difference, why it's not rendering for you. Yes, I was able to get the map background rendered.

Coding-with-Adam avatar Apr 02 '24 16:04 Coding-with-Adam

hi @tuopouk I'm not sure what's the difference, why it's not rendering for you. Yes, I was able to get the map background rendered.

@Coding-with-Adam Did you use the general default token or a custom token?

tuopouk avatar Apr 02 '24 18:04 tuopouk

I used a custom token. You?

Coding-with-Adam avatar Apr 05 '24 17:04 Coding-with-Adam

@Coding-with-Adam I think that what you call a general token is a mapbox token, while a custom one is got from stadiamaps.com. Isn't it?

empet avatar Apr 05 '24 18:04 empet

Hello, I'm also having this problem, using plotly version 5.20. When using the follow code I get a map with no background.

stadio_token = 'my_stadiamaps_token'
fig = px.scatter_mapbox(df, 
                        lat='lat', 
                        lon='long, 
                        color='categorical_chain_name',
                        center=dict(lat=51.44, lon=7.35), 
                        zoom=12,
                        hover_name='categorical_chain_name'
                        )

fig.update_layout(mapbox_style="stamen-terrain", mapbox_accesstoken=stadia_token)

fig.update_layout(legend = dict(bordercolor='rgb(100,100,100)',
                                borderwidth=2,
                                itemclick= 'toggleothers',
                                font = dict(family = "Courier", size = 20, color = "black"),

                                x=0.75,
                                y=0.75))

fig.show()

fig.write_html(out.html')

grafik

I have also tried using px.set_mapbox_access_token(stadia_token), with no change. I couldnt find the equivalent method for Stadiamaps. incidentally, there are also no credits being removed from my Stadiamaps quota.

ossings avatar Apr 09 '24 11:04 ossings

This isn't working for me as well. Tried several options without success. Stadia Maps don't appear to be working.

etiennecelery avatar May 23 '24 16:05 etiennecelery