Fixing issues with Jupyter FORC plotting#811
Merged
Merged
Conversation
Collaborator
Author
|
This PR also fixes #480, I believe. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Jupyter notebook compatibility issues with matplotlib backend selection and streamlines the plot saving workflow in the FORC diagram plotting program. The changes include detecting the execution environment (Jupyter vs. normal Python) to set an appropriate matplotlib backend, simplifying the save/display logic by removing interactive prompts, and improving code quality with better Python idioms.
Key changes:
- Added environment detection to conditionally set matplotlib backend for Jupyter vs. standard Python
- Replaced interactive save prompts with direct matplotlib figure interface usage
- Changed colormap from rainbow to viridis and fixed the SF parameter parsing bug
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When running the example file, I had some issues running the
forc_diagramexample. I believe this was due to some issues with the %matplotlib inline command in the program and the TKAgg backend being set in the program. I fixed this in the imports, where the program now checks where it is being called from and sets a backend based on this.As I dove into this, there was some redundancy in the plot saving which I've now attempted to streamline. Simply, if the
-savflag is used, the file will be saved, as usual. Otherwise, the figure will appear, again, as usual, and the user can save the Figure directly from the Matplotlib figure interface. This replaces the user input which was getting in trouble with theplt.show()commands and saving blank figures.I also changed the colormap from rainbow to viridis. Hehe.