Multiple lines in same trace

#1

Using plotlyjs geo projection - the examples here show each trace being defined like
{
type: ‘scattergeo’,
lat: [all lats],
lon: [all lons],
mode: ‘lines’
}

This creates a separate trace for each line shown on the projection. I’d like to have several non-continuous lines in the same trace for filtering purposes. Is this possible with plotlyjs?

#2

Simply add null in your lon/lat arrays where you want the breaks.

See https://rreusser.github.io/plotly-mock-viewer/#geo_connectgaps (open up the console to see the graph’s data/layout)

#3

Thanks, that did it!

#4

I’m using plotly to visualize complex networks, and was having the same problem where the line would connect every consecutive node (so all edges were a single line). Multiple traces was too slow, this worked like a charm!