All the mapbox examples so far have dark style, can I change its style to white or blue ?
You can - see https://plot.ly/python/scattermapbox/. In particular, then
style attribute inside
layout can be
'satellite-streets'. You can play around with the style of the map in the chart editor GUI at https://plot.ly/create
So you need pro to do this? Or am I missing something? is it possible to load a mapbox style directly?
@Krulvis I don’t see that menu option either
Loading the default styles externally seems to work,
style = ‘mapbox://styles/mapbox/light-v9’
style = ‘mapbox://styles/mapbox/dark-v9’
But if I try loading my own custom mapbox style, the tiles won’t load.
Maybe it’s linked to plotly in general. I get similar results when I use the
same here - having custom map styles enabled would be a game changer!
One way around this is to create your own style in mapbox and call it from dash. For example I created my own style and just called it to dash.
mapbox = dict(
accesstoken = mapbox_access_token,
style = ‘mapbox://styles/srepho/cjttho6dl0hl91fmzwyicqkzf’
All due respect…I’ve tried your style and many others, and no styles other than the defaults (e.g., light, dark, etc.) load. Plotly needs to update their documentation saying that Scattermapbox does not currently take custom style urls.
Here is the official documentation for Mapbox layers and styles: https://plot.ly/python/mapbox-layers/#base-maps-in-layoutmapboxstyle (accurate as of
plotly 4.1.1!) These docs apply whenever you are using
In there you’ll find information about the various built-in styles and the conditions under which you do or don’t require a Mapbox server token
I’m happy to help interpret and upgrade these docs as required!
Regarding “custom style URLs”: these are supported, but I believe they are token-specific, meaning you have to create your own style linked to your own tokens.
@ayanke, there was a bug in plotly mapbox traces that prevented custom styles from loading that was introduced in 1.49.0 of plotly.js and fixed in 1.49.4. This affects plotly.py 4.1.0 and Dash versions 1.1.0 and 1.1.1.
Can you verify that you are not using any of the versions I mentioned above? (you can use
pip list or
conda list to show what packages you have installed)
Yes, that did it Michael. I searched a fair amount for a solution, but this thread is the only one I have found so far that explicitly mentions a fix…even if it means a simple update to plotly haha. Thank you very much! I wish more of my problems could be solved that way…