-
Notifications
You must be signed in to change notification settings - Fork 14
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
Refactor overlay drawing to use fewer artists #1614
Conversation
I am testing with the Seems like everything between the lines is being masked now. Additionally the |
For all overlay types, we were using more artists than we needed to. For powder overlays, for instance, we would have one artist per line. For Laue and rotation series overlays, we would have one artist per spot and one artist per range! This could easily result in hundreds of artists. However, if everything about the artists (including the style) are identical, except for the data, we are able to merge them together into a single artist. This can make matplotlib run much faster. For line artists, we can have a single artist draw every powder overlay line - we just insert a `[nan, nan]` row in between lines in the data. Different artists are used for different styles (i. e., merged ranges are red instead of green, so they get a different artist, and highlighted data/ranges are a different color too, so they get a different artist). But we end up using only about 5 line artists in total for the main canvas, per overlay and per detector (each detector is currently rendered separately). For scatter (path) artists, we ought to just pass every single spot to a single call to `scatter()`. These changes speed up rendering of the overlays significantly, especially when there were many lines or spots being drawn. This is a great step toward better interactivity. Signed-off-by: Patrick Avery <[email protected]>
Since the `rbnds` are no longer sorted in start/stop pairs, we have to add some logic to handle it better. We don't want to go back to the start/stop pair setup because it was error-prone and would make overlay rendering a little slower. Signed-off-by: Patrick Avery <[email protected]>
8c2b880
to
cf9b726
Compare
Signed-off-by: Patrick Avery <[email protected]>
@bnmajor Can you give it a try again? It should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
This doesn't matter for most examples, which have all zeros for their tvec_s. However, it is important to include this for the examples that do. Signed-off-by: Patrick Avery <[email protected]>
For all overlay types, we were using more artists than we needed to. For powder overlays, for instance, we would have one artist per line. For Laue and rotation series overlays, we would have one artist per spot and one artist per range! This could easily result in hundreds of artists.
However, if everything about the artists (including the style) are identical, except for the data, we are able to merge them together into a single artist. This can make matplotlib run much faster.
For line artists, we can have a single artist draw every powder overlay line - we just insert a
[nan, nan]
row in between lines in the data. Different artists are used for different styles (i. e., merged ranges are red instead of green, so they get a different artist, and highlighted data/ranges are a different color too, so they get a different artist). But we end up using only about 5 line artists in total for the main canvas, per overlay and per detector (each detector is currently rendered separately).For scatter (path) artists, we ought to just pass every single spot to a single call to
scatter()
.These changes speed up rendering of the overlays significantly, especially when there were many lines or spots being drawn. This is a great step toward better interactivity.