✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

How to connect lines on Mapbox across the Pacific ocean?

Hello, I’m trying to use python for plotting lines on Mapbox by following example on https://plotly.com/python/lines-on-mapbox/

I used the same code as shown on the example. However, when I tried to create lines from New Zealand to Chile and then back to Australia, the lines wasn’t created across the Pacific ocean.

How can I solve the problem?
Thanks in advance.

import plotly.graph_objects as go

fig = go.Figure(go.Scattermapbox(mode = "markers+lines",  #Wellington >> Canberra >> Sydney
                                 lon = [174, 149, 151], 
                                 lat = [-41, -35, -30], 
                                 marker = {'size': 10}))

fig.add_trace(go.Scattermapbox(mode = "markers+lines",    #Wellington >> Chile >> Sydney
                               lon = [174, -70, 151], 
                               lat = [-41, -33, -30], 
                               marker = {'size': 10}))

fig.update_layout(margin ={'l':0,'t':0,'b':0,'r':0},
                  mapbox = {'center': {'lon': 10, 'lat': 10},
                            'style': "stamen-terrain",
                            'center': {'lon': -20, 'lat': -20},
                            'zoom': 1})
fig.show()