Skip to content

adding example for multiple disconnected lines #2215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2020

Conversation

felixniemeyer
Copy link

I found this feature very helpful for plotting large networks with many many edges.
I think it might be valuable for others who stumble across this article, too.

@jdamiba
Copy link

jdamiba commented Feb 19, 2020

@felixniemeyer Thanks a lot for taking the time to submit this example! It's always awesome to see community members submitting pull requests.

I only have a few minor comments.

First, can you please update your PR so that the example you added has all the code needed to execute it? In our experience, users find it frustrating to not be able to copy/paste entire examples through the use of techniques like # ... omitted code . If you have seen any examples in the documentation that use this pattern please let me know!

Second, can you please provide a screenshot of what the example figure created by your example looks like and explain a little more the motivation behind it? I am having a hard time seeing what you mean by "multiple disconnected lines" when I am looking at the figure in my development environment.

Thanks again!

@emmanuelle
Copy link
Contributor

@jdamiba I think the use case here is that if you have one trace per segment your figure will render more slowly than if you have a single trace of (here interrupted) lines.

@felixniemeyer thanks for your contribution? Would you have the time to address @jdamiba 's comments about having a standalone code cell?

@@ -111,6 +111,33 @@ fig.update_layout(

fig.show()
```
### High performance US Flight Paths Map
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the wording I'm hesitating between faster and much faster here... Do you have orders of magnitude for the two solutions?

@felixniemeyer
Copy link
Author

Thanks for your feedback everybody.

@jdamiba
I've added the omitted code in the example.

@emmanuelle
I did an experiment to clarify the performance improvement
I'm drawing 25,734 lines.

Creating one trace for each line results in:
5min 3sec execution time of the script.
Frame time of ~1500ms
on my computer.

Creating only 4 traces in total and adding multiple lines to them results in:
0min 7sec execution time of the script.
Frame time of ~700ms

--

Here are two people, for whom the "multiple lines in a trace" was the solution to their performance issues:
https://community.plot.ly/t/multiple-lines-in-same-trace/14659

Another use case (besides performance improvement) for this feature of using "None" in the coordinates arrays to start multiple lines within the same trace may arise in combination with drawing a legend:
On the legend, every trace has it's entry. If you have 100 lines each drawn as a separate trace, you would end up having 100 entries in your legend.
If you draw them within one trace, they will have one entry in the legend.

@emmanuelle
Copy link
Contributor

Thank you @felixniemeyer for the update and the benchmark. I just left a last suggestion to improve performance even more :-).

@emmanuelle
Copy link
Contributor

@felixniemeyer did you have the time to look at my suggestion? I'd love to merge this cool example!

@emmanuelle
Copy link
Contributor

@felixniemeyer I merged my suggestion to your branch so that we can merge the PR, I hope you don't mind. Thank you very much for the PR!

@nicolaskruchten nicolaskruchten merged commit d1584a4 into plotly:doc-prod May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants