Weird Scattermapbox lines behaviour

See attached screenshot. How can I fix that weird behaviour? All coords I submit are “in the water” and at 180deg lon there’s a cutoff (they are not connected). It works perfectly fine for every set of coords which “does not cross the pacific”.

Here’s the code:

def update_map_fig(datastore):
        map_fig_updated = go.Figure(go.Scattermapbox(
        mapbox=dict(accesstoken="mytoken"), margin={"r": 0, "t": 0, "l": 0, "b": 0},showlegend=False)
        return map_fig_updated

If you change the mode to ‘markers’ are the markers plotted in the correct spots?

1 Like

good question! Yes, the markers are on the correct spot:

I think the lines could be an issue with how the map works.

What happens when you zoom in with the lines?

1 Like

Screenshot 2023-03-23 at 15.41.36

Very strange…

Might be an issue with the API for mapbox…

In a scatter plot the order of the points defines the lines to be drawn.

I hade something like this in the past:

that cutoff happens right at 180 deg long (and is obviously not visible until fully/max zoomed in)

Since this problem is exclusive to lines that go “around the world”, meaning lines that cross 180 deg lon (and I’m pretty sure the order is correct too) I don’t think that’s it

Yeah, you might be right, just wanted to mention it :wink:

So I have found out that this is in fact a feature, not a bug. Crossing the antimeridian - any tips on how to proceed?

Here’s the solution for future reference:

        #waypoints is a pandas df with columns lon and lat in degrees ranging from -180 to 180
        #the number 180 depends on your "step size", may need customization
        for plusmin_crossing in crossings_plusminus:
        for minusplus_crossing in crossing_minusplus:
        fig = px.line_mapbox(, lon=lons)
1 Like

Thanks for sharing the solution.