# Subloting mapbox in jupyter notebook

**URL:** <https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126>\
**Category:** 📊 Plotly Python\
**Created:** [November 28, 2018, 11:27am UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126 "2018-11-28T11:27:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wats0ns](https://avatars.discourse-cdn.com/v4/letter/w/3d9bf3/32.png) [@wats0ns](https://community.plotly.com/u/wats0ns)\
**Post date:** [November 28, 2018, 11:27am UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126/1 "2018-11-28T11:27:51Z")

</div>

Hey everyone,  
I’m trying to sublots 4 mapbox images. The goal would be to display 4 maps side-by-side, but I can’t find how to do it. Using `append_trace` will throw an error because `Scattermapbox` can’t contain xaxis property, and I haven’t seen any other information. Does anyone know how to do this / knows where I could find a great example of it ?  
Thanks !  
Quentin

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [November 28, 2018, 1:04pm UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126/2 "2018-11-28T13:04:59Z")

</div>

Hi @wats0ns,

You’re right that the `make_subplots`/`append_trace` approach doesn’t support mapbox traces at this point. Your best bet is to set the domain of each mapbox subplot directly. Here’s an example of putting two mapbox traces side by side

```python
import plotly.plotly as py
import plotly.graph_objs as go

mapbox_access_token = 'pk.eyJ1Ijoiam1tZWFzZSIsImEiOiJjamljeWkwN3IwNjEyM3FtYTNweXV4YmV0In0.2zbgGCjbPTK7CToIg81kMw'

data = [
    go.Scattermapbox(
        lat=['45.5017'],
        lon=['-73.5673'],
        mode='markers',
        marker=dict(
            size=14
        ),
        text=['Montreal'],
        subplot='mapbox',
    ),
    go.Scattermapbox(
        lat=['45.5017'],
        lon=['-73.5673'],
        mode='markers',
        marker=dict(
            size=14
        ),
        text=['Montreal'],
        subplot='mapbox2',
    )
]

layout = go.Layout(
    autosize=True,
    hovermode='closest',
    mapbox=dict(
        accesstoken=mapbox_access_token,
        domain={'x': [0, 0.4], 'y': [0, 1]},
        bearing=0,
        center=dict(
            lat=45,
            lon=-73
        ),
        pitch=0,
        zoom=5
    ),
    mapbox2=dict(
        accesstoken=mapbox_access_token,
        domain={'x': [0.6, 1.0], 'y': [0, 1]},
        bearing=0,
        center=dict(
            lat=45,
            lon=-73
        ),
        pitch=0,
        zoom=5
    ),
)

fig = go.FigureWidget(data=data, layout=layout)
fig

```

 ![newplot%20(1)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/3/3694013fcd20ce7d655acb1742283dcdb18669c5.png)

The key properties to notice are the `subplot` property of the mapbox traces and the `domain` property of each mapbox subplot in the `layout` section. You can continue the pattern with `mapbox3`, `mapbox4`, etc.

Hope that helps!  
-Jon

---

<div class="post-metadata">

**Author:** ![wats0ns](https://avatars.discourse-cdn.com/v4/letter/w/3d9bf3/32.png) [@wats0ns](https://community.plotly.com/u/wats0ns)\
**Post date:** [November 28, 2018, 2:55pm UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126/3 "2018-11-28T14:55:00Z")

</div>

Hey @jmmease, thanks for the quick answer, however this gives me the following error:  
`ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: 'mapbox2'`

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [November 28, 2018, 3:12pm UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126/4 "2018-11-28T15:12:41Z")

</div>

Try upgrading your version of plotly.py (I’m on 3.4.2).  
-Jon

---

<div class="post-metadata">

**Author:** ![wats0ns](https://avatars.discourse-cdn.com/v4/letter/w/3d9bf3/32.png) [@wats0ns](https://community.plotly.com/u/wats0ns)\
**Post date:** [November 28, 2018, 3:26pm UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126/5 "2018-11-28T15:26:25Z")

</div>

That was it ! Do you know how I could name each of the subplot (like a title) ?

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [November 29, 2018, 11:13am UTC](https://community.plotly.com/t/subloting-mapbox-in-jupyter-notebook/16126/6 "2018-11-29T11:13:06Z")

</div>

There’s not a direct way to create subplot titles with this approach. What the `make_subplots` function does underneath is position annotations in paper coordinates as the titles. Here’s an example of doing this to create custom axis labels ([https://plot.ly/python/text-and-annotations/#adding-annotations-with-xref-and-yref-as-paper](https://plot.ly/python/text-and-annotations/#adding-annotations-with-xref-and-yref-as-paper)). You could use the same approach for subplot titles, it will just take some fiddling to position the annotations where you want them.

Hope that helps!  
-Jon
