# Multiple lines in same trace

**URL:** <https://community.plotly.com/t/multiple-lines-in-same-trace/14659>\
**Category:** plotly.js\
**Created:** [October 17, 2018, 3:45pm UTC](https://community.plotly.com/t/multiple-lines-in-same-trace/14659 "2018-10-17T15:45:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbaile30](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sbaile30](https://community.plotly.com/u/sbaile30)\
**Post date:** [October 17, 2018, 3:45pm UTC](https://community.plotly.com/t/multiple-lines-in-same-trace/14659/1 "2018-10-17T15:45:47Z")

</div>

Using plotlyjs geo projection - the examples [here](https://plot.ly/javascript/lines-on-maps/) 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?

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [October 25, 2018, 4:03pm UTC](https://community.plotly.com/t/multiple-lines-in-same-trace/14659/2 "2018-10-25T16:03:30Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![sbaile30](https://avatars.discourse-cdn.com/v4/letter/s/3ab097/32.png) [@sbaile30](https://community.plotly.com/u/sbaile30)\
**Post date:** [October 25, 2018, 5:55pm UTC](https://community.plotly.com/t/multiple-lines-in-same-trace/14659/3 "2018-10-25T17:55:30Z")

</div>

Thanks, that did it!

---

<div class="post-metadata">

**Author:** ![Juan1](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/juan1/32/6676_2.png) [@Juan1](https://community.plotly.com/u/Juan1)\
**Post date:** [May 8, 2019, 8:07pm UTC](https://community.plotly.com/t/multiple-lines-in-same-trace/14659/4 "2019-05-08T20:07:07Z")

</div>

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!
