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

Move draw_if_interactive logic to new_figure_manager_given_figure. #468

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 2, 2022

Currently, Matplotlib only ever calls draw_if_interactive at the end of
plt.figure() (and upon figure unpickling), i.e. this is a mechanism to
further customize handling of newly generated figures. (Prior to
Matplotlib 1.5, draw_if_interactive was also called at the end of all
pyplot functions to trigger a figure redraw, but this is now handled by
the stale attribute.)

In order to simplify the backend API ("what is the API that a backend
module must/can provide", I am planning to deprecate (on Matplotlib's
side) the ability for backends to provide a draw_if_interactive
function (forcing them to always do if interactive(): draw_idle()) (matplotlib/matplotlib#23105).
Instead, any relevant new-figure-customization logic can instead go
into new_figure_manager_given_figure. This PR implements this change
for ipympl, and should be fully back-compatible all the way back to
Matplotlib 1.5. I would like to make these changes first on the side
of the clients (i.e., the third-party backends), to catch any possible
problems with the intended change on Matplotlib's side.

Currently, Matplotlib only ever calls draw_if_interactive at the end of
`plt.figure()` (and upon figure unpickling), i.e. this is a mechanism to
further customize handling of newly generated figures.  (Prior to
Matplotlib 1.5, draw_if_interactive was also called at the end of all
pyplot functions to trigger a figure redraw, but this is now handled by
the stale attribute.)

In order to simplify the backend API ("what is the API that a backend
module must/can provide", I am planning to deprecate (on Matplotlib's
side) the ability for backends to provide a draw_if_interactive
function (forcing them to always do `if interactive(): draw_idle()`).
Instead, any relevant new-figure-customization logic can instead go
into `new_figure_manager_given_figure`.  This PR implements this change
for ipympl, and should be fully back-compatible all the way back to
Matplotlib 1.5.  I would like to make these changes first on the side
of the clients (i.e., the third-party backends), to catch any possible
problems with the intended change on Matplotlib's side.
@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2022

Binder 👈 Launch a binder notebook on branch anntzer/ipympl/udif

@anntzer
Copy link
Contributor Author

anntzer commented Jun 3, 2022

As for #466, the visual regression tests fail even on master, independently of this PR.

@anntzer
Copy link
Contributor Author

anntzer commented Jun 16, 2022

@ianhi any chance you can have a look at this? thanks :)

Copy link
Collaborator

@ianhi ianhi left a comment

Choose a reason for hiding this comment

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

seems good to me! thakns for the ping

@ianhi
Copy link
Collaborator

ianhi commented Jun 16, 2022

and thanks also for the PR! makes following the backend changes in matplotlib much nicer :)

@ianhi ianhi merged commit 8a3740d into matplotlib:main Jun 16, 2022
@anntzer anntzer deleted the udif branch June 16, 2022 22:13
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