Skip to content

Commit a5ee4ca

Browse files
author
fairlix
authored
adding example for multiple disconnected lines
1 parent 59cf184 commit a5ee4ca

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/python/lines-on-maps.md

+27
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,33 @@ fig.update_layout(
111111

112112
fig.show()
113113
```
114+
### High performance US Flight Paths Map
115+
If you can relinquish having individual styles for the flight paths (e.g. opacity), you can put multiple paths into one trace, which makes the map render much faster.
116+
117+
Use ```None``` between path coordinates to create a break in the otherwise connected paths.
118+
119+
```python
120+
# ... omitted code: look at the previous "US Flight Paths Map" example
121+
lons = []
122+
lats = []
123+
for i in range(len(df_flight_paths)):
124+
# None interrupts lines and makes it possible to draw multiple disconnected lines.
125+
lons += [df_flight_paths['start_lon'][i], df_flight_paths['end_lon'][i], None]
126+
lats += [df_flight_paths['start_lat'][i], df_flight_paths['end_lat'][i], None]
127+
128+
fig.add_trace(
129+
go.Scattergeo(
130+
locationmode = 'USA-states',
131+
lon = lons,
132+
lat = lats,
133+
mode = 'lines',
134+
line = dict(width = 1,color = 'red'),
135+
opacity = 0.5
136+
)
137+
)
138+
# ... omitted code: look at the previous "US Flight Paths Map" example
139+
```
140+
114141

115142
### London to NYC Great Circle
116143

0 commit comments

Comments
 (0)