I am trying to create a map, where I need to draw a line between several nodes/points. There is approximately 2000 node pairs that need a line drawn between them.
I have a data frame containing the longitude/latitude coords for each node pair (i.e. col1 and col2), and then I plot it by the following:
fig = go.Figure(go.Scattergeo())
for idx, row in df.iterrows():
fig.add_trace(
go.Scattergeo(
mode="markers+lines",
lat=[row["col1"][0], row["col2"][0]],
lon=[row["col1"][1], row["col2"][1]],
marker={"size": 10},
)
)
fig.show()
So I just run through the data frame and plot each node pair. However, my issue is that if I plot beyond 400-500 pairs, the resulting plot is very slow to render, and the zoom/drag effect are also not very good.
I am not sure if I can optimize on this. I'm guessing the issue is that I create that many add_trace objects, but I can't seem to figure out how else to draw a line between pairs only. If I just give all latitude and longitude coords to the lat and lon args, then I will plot all points, and then just draw a line between everything - which is not intended.
So yeah, any ideas ?