Can I change Mapbox color style in Dash?

Hi,
All the mapbox examples so far have dark style, can I change its style to white or blue ?
thanks

You can - see https://plot.ly/python/scattermapbox/. In particular, then style attribute inside mapbox inside layout can be 'light', 'basic', 'outdoors', 'satellite', or 'satellite-streets'. You can play around with the style of the map in the chart editor GUI at https://plot.ly/create

1 Like

So you need pro to do this? Or am I missing something? is it possible to load a mapbox style directly?

2 Likes

@Krulvis I don’t see that menu option either

image

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.

It appears a few other have had this challenge too
Custom Mapbox Studio style in Dash
Hide specific layer from generic mapbox map

Maybe it’s linked to plotly in general. I get similar results when I use the plotly.graph_objs library.

Any thoughts @chriddyp @bcd?

1 Like

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 scattermapbox, choroplethmapbox or densitymapbox traces.

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

I’m happy to help interpret and upgrade these docs as required!

1 Like

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.

1 Like

@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)

2 Likes

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…