Add a draw during show for macos backend by ksunden · Pull Request #27955 · matplotlib/matplotlib · GitHub
Skip to content

Add a draw during show for macos backend - #27955

Merged
tacaswell merged 1 commit into
matplotlib:mainfrom
ksunden:macos_show_draw
Apr 3, 2024
Merged

tacaswell merged 1 commit into
matplotlib:mainfrom
ksunden:macos_show_draw

Conversation

@ksunden

@ksunden ksunden commented Mar 20, 2024

Copy link
Copy Markdown
Member

Without this a stale figure is shown

PR summary

This is basically the same concept as what happens just before show in plt.pause.

Essentially, there is nothing in the macos backend that actually causes a stale figure to be redrawn on show.
Other backends (qt, tk in particular, but likely others) seem to be saved by the fact that a resize event is triggered upon show, but macos does not do the same.

Other ideas considered, would be to do this in plt.show (which would perhaps leave out some other mechanisms, such as mpl-gui) or to try and do this in backend_bases (which is hard because most do not call super).
Could also leave out the condition and just always call draw_idle.

closes #27953

PR checklist

Without this a stale figure is shown
@QuLogic QuLogic added this to the v3.8.4 milestone Mar 21, 2024
@QuLogic
QuLogic requested a review from greglucas March 21, 2024 00:27

@greglucas greglucas 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.

Thanks for the pointer about this needing to be run in a terminal and not a script. I can reproduce the original issue that way.

This fixes the issue, so has my approval and is good to go in. But I am still not sure whether there is a deeper issue here with the way we are setting the interrupt handling that this is just covering up in a sense by forcing another event through.

In the __init__ method, we are actually following the call to self.show() with a draw_idle(). I'm wondering if we can either remove that call now, or if we should just be calling draw_idle() here regardless of whether we are stale or not like above.

@ksunden

ksunden commented Apr 1, 2024

Copy link
Copy Markdown
Member Author

@tacaswell
tacaswell merged commit d0faf22 into matplotlib:main Apr 3, 2024
@ksunden
ksunden deleted the macos_show_draw branch April 3, 2024 19:11
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Apr 3, 2024
QuLogic added a commit that referenced this pull request Apr 3, 2024
…955-on-v3.8.x

Backport PR #27955 on branch v3.8.x (Add a draw during show for macos backend)
@ksunden ksunden mentioned this pull request Apr 4, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Pyplot can no longer set axes properties

4 participants