Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix draw on show #4503

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

Merged
merged 6 commits into from
Jun 28, 2015
Merged

Fix draw on show #4503

merged 6 commits into from
Jun 28, 2015

Conversation

tacaswell
Copy link
Member

Fixes one of the issues raised in comments on b2fbae7

This needs testing on gtk, gkt3, wx, and osx, but I am pretty confident it will work (or at least do no harm).

tacaswell added 2 commits June 7, 2015 22:47
If a window is shown due to being in interactive mode, call
draw_idle.  This draw will be executed when the next time
python is idle.  This makes running plotting scripts with

  python -i test.py

correctly auto-display/draw when dropping into the repl.
@tacaswell tacaswell added this to the next point release milestone Jun 8, 2015
tacaswell referenced this pull request Jun 8, 2015
With the repl callback the pyplot function do not need to
call `draw_if_interactive`.
@tacaswell
Copy link
Member Author

note to self: look at how nbagg deals with this (which is a bit funny) and maybe currently broken.

@OceanWolf You should be aware of this for your Gcf related PR.

@OceanWolf
Copy link
Member

Ahh, thanks for the heads up.

@tacaswell tacaswell mentioned this pull request Jun 8, 2015
@WeatherGod
Copy link
Member

@tacaswell , is the note to self an indication that you want to expand this PR to include nbagg, or that nbagg would need to be worked on in a separate PR?

@@ -1236,6 +1236,7 @@ def new_figure_manager_given_figure(num, figure):
figmgr = frame.get_figure_manager()
if matplotlib.is_interactive():
figmgr.frame.Show()
figure.canvas.draw_idle()
Copy link
Member

Choose a reason for hiding this comment

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

I seem to recall that draw_idle() in wx can be broken sometimes. Would it make sense to make all of these be figure.canvas.draw() instead as this isn't a performance-critical portion of the code? We should probably guarantee an image upon initial display.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mdehoon convinced me that in almost all cases we want to use draw_idle to play nice with the crankier event loops (and most of the backends have some 'I have been told to draw, but have not' so the later calls to draw_idle get no-oped, rather than stacking up draw commands.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, now re-reading this and understanding it correctly. I think you are reffering to the issue fixed by #3905 so I am inclined to leave this as-is unless a Wx users says otherwise.

 - white space clean up
 - removed dead (commented out) code
 - moved `is_interactive` import to top of file
 - remove unused import (contextmanager, backend_agg)
dicts have a len, do not need to get length of the values list/iterator.
Removing the `draw_if_interactive` from `pyplot.figure` in
b2fbae7 causes the figures to no longer
be shown on creation in nbagg, this special-cases the manager creating
in nbagg to ensure that the figure is indeed shown.

The root cause of this is that unlike every other backend which call
`show` in either the Manager `__init__` or one of the
`new_figure_manager` functions, nbagg did not
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jun 27, 2015
@tacaswell
Copy link
Member Author

I think this ready to go again.

efiring added a commit that referenced this pull request Jun 28, 2015
@efiring efiring merged commit 326ccd6 into matplotlib:master Jun 28, 2015
@tacaswell tacaswell deleted the fix_draw_on_show branch June 28, 2015 03:59
efiring referenced this pull request Jul 12, 2015
There is still one `draw_if_interactive` left in the `rcdefaults`
call as the current scheme does not track when rcparams change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants