-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
WIP: Don't draw_idle in non-GUI backends #5800
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
Conversation
.... well fine that does make more sense that the epicycles I added to make it only draw one extra time. There is a bunch more logic that should be ripped out and I suspect the failing tests just need to have explicit |
just to be clear, the tone in my last comment should be mild embarrassment that I did not see that solution. Only concern is that it is a mild back compatibility break and if people are using a) the plt.plot(range(50))
plt.gca().get_xlim() # this result changes under this behavior |
That's a good point, and exactly the kind of thing I was hoping you'd help find. I suppose what we ought to do is |
Also, I would wonder if animations would break while in an AGG backend? I On Tue, Jan 5, 2016 at 10:22 AM, Michael Droettboom <
|
I've updated this so @WeatherGod: I've confirmed that animation works with this change, both when saving to a file and "live" in TkAgg, Qt4Agg and NbAgg. |
@tacaswell: Not sure how to milestone this. It's a pretty important performance improvement, but also has some potential for accidental consequences given how "core" it is. |
d7dcda9
to
8fa66a6
Compare
@@ -2021,7 +2021,7 @@ def draw_idle(self, *args, **kwargs): | ||
""" | ||
:meth:`draw` only if idle; defaults to draw but backends can overrride |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps mention the interactive-only behavior in the docstring?
@@ -235,35 +239,40 @@ def test_axes_titles(): | ||
|
||
@cleanup | ||
def test_set_position(): | ||
fig, ax = plt.subplots() | ||
plt.ion() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a plt.ioff()
call in the cleanup
decorator?
I have been thinking about this a bit more recently and coming around to If it is better to make this a no-op here and require that the sub-classes that want to provide it do or to leave this as-is and make the backends that do not want to provide it to over-ride with a no-op is not clear to me yet. |
This is very stale. I can't tell if this is a good idea or not... |
As far as I can tell, there's no opposition here, only unsure about any broader ramifications. This seems generally like a good idea to me... |
The change in backend_bases looks good, and long overdue, though I haven't actually tried it and might be missing something. |
We have made other changes to the tests that I think actually eliminate most of the changes to the tests. |
|
I think that this PR pre-dates the ability to push to contributor branches, I'll open a new one. |
Closed in favor of #17923 |
Consider this a "proposed" PR, since I have a feeling the solution can't possibly be this easy.
While doing some timings on image drawing, I just discovered that running something like the following:
results in the entire figure being drawn twice. Once to save the file, and then again as the result of
draw_idle
. It seems thatdraw_idle
really shouldn't do anything in a non-GUI backend.Making
draw_idle
a no-op in the canvas base class seems to address this, and all the GUI backends overridedraw_idle
anyway. This behavior seems to have been here for a very long time.I can't seem to see how this breaks things, by @tacaswell has been down in the weeds of
draw_idle
more recently... Maybe he has some ideas as to why this is necessary.