-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add ax arg to plot method #44
Merged
IgorTatarnikov
merged 18 commits into
brainglobe:main
from
RobertoDF:ax-argument-to-heatmap
Jul 24, 2024
Merged
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6a311fe
Add ax arg to plot method
RobertoDF 6a3ab74
typo fix
RobertoDF cd176a1
fix typo
RobertoDF 85b339b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f5c17b7
Add show_cbar arg
RobertoDF ab90013
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f3c3d07
solve ruff error
RobertoDF 7e9d914
re-add plt.show()
RobertoDF 57a651e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8db7529
Reproduce previous behavior
RobertoDF 827e433
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a10d5c3
Solve ax reference bug
RobertoDF 53d89b4
Refactored into two functions
IgorTatarnikov a6af1e5
Added the example script for plotting subplots
IgorTatarnikov 8e64955
Add float to distance typehint
IgorTatarnikov f1e98f8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 3f21f28
Added comments in the example script
IgorTatarnikov e8610a2
Merge branch 'ax-argument-to-heatmap' of https://github.com/RobertoDF…
IgorTatarnikov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This breaks backwards compatibility right?
Could this be made to still behave as before (unless you pass the new arguments), please?
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.
sure, thanks for the quick answer.
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.
Does this work?
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.
I can see the figure in a fresh conda environment with Python 3.10, but not in fresh conda environments with Python 3.11 or 3.12. In all cases, I get a segmentation fault (after closing the figure in 3.10).
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.
I am on Ubuntu 22.04
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.
Even more weird: if i define the plotting function outside jupyter (so I import it with from Utils.Utils import plot_brainrender_heatmaps) everything works perfectly without crashing.
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.
Hey all! I ran into the same seg fault on Ubuntu. A small change in the example script fixed it for me:
My best guess is that matplotlib does something lazily when plotting, and the garbage collector was being really eager and freeing the memory for each scene before
plt.show()
was called. Keeping a reference to each scene active fixed the seg fault for me!I'm not sure if this is something we should address within the implementation or if it's best to publish this example script somewhere in the docs as the "proper" way of doing it.
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.
Do you have a sense of how easy it would be to address this in the implementation?
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.
I think this could be addressed by somehow changing
Heatmap
to allow storing multiple slicers internally, that way instead of this being done in a for loop you'd initialize one scene with multiple 2D positions. Then theplot()
function can have internal logic to check if multiple slicers are present and provide a figure with a subplot for each slicer.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.
Just realised I didn't actually answer your question! In terms of ease I'd say it wouldn't be too bad, just a bit more refactoring. The main thing I'd worry about is adding too many conditionals, or how to expose this to the user without overloading the position argument in the
__init__
further!