Skip to content

ScatterMapbox subplots not working #1728

Closed
@Timost

Description

@Timost

Hi,
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:
Screenshot from 2019-08-19 20-04-14
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions