Skip to content
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

Use a tight bounding box when plotting at the intrinsic size #5437

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

seeM
Copy link
Contributor

@seeM seeM commented Nov 21, 2024

Addresses #5068. This brings our matplotlib configuration closer to Jupyter Notebooks when using the intrinsic sizing policy which is probably more familiar to users.

Since the produced image pixel size is no longer guaranteed, I also changed the save plot modal to display the size in intrinsic units instead of pixels.

Known Issues

If you plot totally outside of the default bounding box, it's missed by our current plot change detection and an "update" is not sent to the frontend. I was unable to find a fix in a reasonable amount of fiddling.

It's a bit of a hack but you can manually request an update with fig.canvas.manager.update(). Maybe a better workaround would be to add a refresh button to the plots action bar?

QA Notes

Running the following code in a single execution should include the title in the plot (you can't run it line-by-line because of the known issue above).

fig, ax = plt.subplots()
fig.text(x=0.5, y=1, s='title')
plt.show()

Copy link
Contributor

@timtmok timtmok left a comment

Choose a reason for hiding this comment

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

I've wondered if we should add a refresh button. It does seem like a workaround if the plot needs it and the button bar is starting to get crowded. It could probably use a bit of a UI change to handle all these actions.

The changes look good! I think there might be an update needed to the automated tests but I don't think those tests do anything with intrinsic size.

@seeM seeM merged commit 4c20d05 into main Nov 25, 2024
23 checks passed
@seeM seeM deleted the 5068-fix-matplotlib-layout branch November 25, 2024 18:05
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants