Skip to content

Fixing issues with Jupyter FORC plotting#811

Merged
apivarunas merged 5 commits into
PmagPy:masterfrom
apivarunas:forc-issues
Dec 4, 2025
Merged

Fixing issues with Jupyter FORC plotting#811
apivarunas merged 5 commits into
PmagPy:masterfrom
apivarunas:forc-issues

Conversation

@apivarunas

Copy link
Copy Markdown
Collaborator

When running the example file, I had some issues running the forc_diagram example. 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 -sav flag 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 the plt.show() commands and saving blank figures.

I also changed the colormap from rainbow to viridis. Hehe.

@apivarunas

Copy link
Copy Markdown
Collaborator Author

This PR also fixes #480, I believe.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread programs/forc_diagram.py
Comment thread programs/forc_diagram.py
Comment thread programs/forc_diagram.py
Comment thread programs/forc_diagram.py
Comment thread programs/forc_diagram.py Outdated
Comment thread programs/forc_diagram.py Outdated
@apivarunas apivarunas merged commit c953916 into PmagPy:master Dec 4, 2025
2 checks passed
@apivarunas apivarunas deleted the forc-issues branch December 4, 2025 07:18
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.

2 participants