ScatterMapbox subplots not working
See original GitHub issueHi, First of all thank you for making plotly. It’s amazing. I’ve been trying to make a subplot of ScatterMapbox (e.g.: Two maps, one below the other) without success. I’m trying this in a jupyter notebook:
- linux debian buster
- Firefox 68.0.1
- python 3.6.9
- jupyter 1.0.0
- plotly 4.1.0
The code I use is:
fig = make_subplots(
rows=2, cols=1,
specs=[[{'type': 'mapbox'}],[{'type': 'mapbox'}]],
subplot_titles=('Montreal 1','Montreal 2'),
)
fig.add_trace(go.Scattermapbox(
lat=['45.5017'],
lon=['-73.5673'],
mode='markers',
marker=go.scattermapbox.Marker(
size=14
),
text=['Montreal'],
), row=1, col=1
)
fig.add_trace(go.Scattermapbox(
lat=['45.6017'],
lon=['-73.7673'],
mode='markers',
marker=go.scattermapbox.Marker(
size=14
),
text=['Montreal 2'],
), row=2, col=1
)
fig.update_layout(
hovermode='closest',
mapbox=go.layout.Mapbox(
accesstoken=mapbox_access_token,
bearing=0,
center=go.layout.mapbox.Center(
lat=45,
lon=-73
),
pitch=0,
zoom=5
)
)
fig.show()
This results in an empty map: In my browser console I have:
Error: No valid mapbox style found, please set `mapbox.style` to one of:
open-street-map, white-bg, carto-positron, carto-darkmatter, stamen-terrain, stamen-toner, stamen-watercolor
or register a Mapbox access token to use a Mapbox-served style.
Passing a mapbox_style
to the layout does not seem to solve the issue.
Note that running the simple montreal example from the doc works properly, even adding a single map to the subplot works too:
fig = make_subplots(
rows=2, cols=1,
specs=[[{"type": "mapbox"}],[{"type": "mapbox"}]],
subplot_titles=("Montreal 1","Montreal 2"),
)
fig.add_trace(go.Scattermapbox(
lat=['45.5017'],
lon=['-73.5673'],
mode='markers',
marker=go.scattermapbox.Marker(
size=14
),
text=['Montreal'],
), row=1, col=1
)
fig.update_layout(
hovermode='closest',
mapbox=go.layout.Mapbox(
accesstoken=mapbox_access_token,
bearing=0,
center=go.layout.mapbox.Center(
lat=45,
lon=-73
),
pitch=0,
zoom=5
)
)
fig.show()
I’ve tried passing multiple Scattermapbox
to a figure’s data but this results in two mapbox layers in the same map. At this point I’m starting to think that subplots are not supported with scattermapbox but as could not find anything regarding this in the docs, I’m probably missing something.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
@Timost If you want the styles to be the same across all of your subplots you can also run:
This will mean you won’t need to call add
mapbox{n}_style
n times.@bandersen23 Life saver!