Can a mapbox trace be *behind* a mapbox map?

I’m interested in a plot with the following layers, background to foreground:

  1. a choropleth plot
  2. a mapbox map (mostly transparent, just with streets)

is this possible? if so, how?

basically, i’d like to superimpose some map info (e.g. streets, some POIs) over a choropleth.

in other words, i’d like the trace to be under or behind the mapbox map defined by mapbox_style. i see that graph_objects mapbox traces accept a below argument, but this seems only in relation to other traces.

Yes, layers are displayed in the order they appear in the layers list: https://plotly.com/python/mapbox-layers/

1 Like

Thanks! I understand now.

How do I find out the valid layer names that I can reference for a given 'mapbox_style'?

I was trying to figure this out via Mapbox studio. I cloned Streets v8 into my own style and then could see layer names in the Studio GUI. But, some layer names didn’t work with plotly, like aeroway-polygon, while others, like road-primary (maybe roads-primary) did work. That issue aside, seems like Mapbox Studio is one way, or also using the MapboxGL js library… But this only works for custom styles.

Any help with figuring out what layer names I can reference with below would be appreciated.

Perhaps this a feature request, but it’d be great if the error message for when I supply an invalid / unrecognized layer name told me what the valid ones are.

Yes, it would be great to have error messages like this but we’ve not figured out how to bubble them up from the Javascript level back to the Python level :slight_smile:

It’s also a challenge to introspect the big bundle of layers that come in via a mapbox style, we don’t have a good way of letting you explore that at the moment, sorry!

1 Like