'How to make plotly.express.line lines not to connect between one another?

I am new to plotly and I am trying to draw some roads on a map in different colors based on the traffic value.

This is what I tried:

fig = px.line_mapbox(lat=test_lat, lon=test_long, hover_name=test_name,mapbox_style = 'carto-positron',color =test_trafic)
fig.show()

Where test_lat is an array with latitudes points, test_long is an array with longitudes, test_name are the names of the streets and test_trafic are the values of traffic.

The problem is that, when I run it, although the streets appear correctly on the map, plotly connects all the lines between them like this:

enter image description here

Is there a way to fix this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source