Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mdboom wants to merge3 commits intomatplotlib:masterfrommdboom:dont-double-draw

Conversation

mdboom
Copy link
Member

@mdboommdboom commentedJan 5, 2016
edited by dopplershift
Loading

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:

importmatplotlibmatplotlib.use('Agg')frommatplotlibimportpyplotaspltplt.plot([1,2,3])plt.savefig("test.png")

results in the entire figure being drawn twice. Once to save the file, and then again as the result ofdraw_idle. It seems thatdraw_idle really shouldn't do anything in a non-GUI backend.

Makingdraw_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 ofdraw_idle more recently... Maybe he has some ideas as to why this is necessary.

@tacaswell
Copy link
Member

.... well fine that does make more sense that the epicycles I added to make it only drawone extra time.

There is a bunch more logic that should be ripped out and I suspect the failing tests just need to have explicitdraw calls added to force updates.

@tacaswell
Copy link
Member

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) thepyplot api b)plt.ion c) a non interactive backend this could break things if they do

plt.plot(range(50))plt.gca().get_xlim()# this result changes under this behavior

@mdboom
Copy link
MemberAuthor

Only concern is that it is a mild back compatibility break and if people are using a) the pyplot api b) plt.ion c) a non interactive backend this could break things if they do

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 isif ion() ... do what we currently do in draw_idle ... else: pass.

@WeatherGod
Copy link
Member

Also, I would wonder if animations would break while in an AGG backend? I
can't remember if draw() or draw_idle() is used in animations.

On Tue, Jan 5, 2016 at 10:22 AM, Michael Droettboom <
notifications@github.com> wrote:

Only concern is that it is a mild back compatibility break and if people
are using a) the pyplot api b) plt.ion c) a non interactive backend this
could break things if they do

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 if ion() ... do what we currently
do in draw_idle ... else: pass.


Reply to this email directly or view it on GitHub
#5800 (comment)
.

@mdboom
Copy link
MemberAuthor

I've updated this sodraw_idle is only a no-op ifinteractive isFalse.

@WeatherGod: I've confirmed that animation works with this change, both when saving to a file and "live" in TkAgg, Qt4Agg and NbAgg.

@mdboom
Copy link
MemberAuthor

@tacaswell: Not sure how to milestone this. It's a pretty important performance improvement, but also hassome potential for accidental consequences given how "core" it is.

@@ -2021,7 +2021,7 @@ def draw_idle(self, *args, **kwargs):
"""
:meth:`draw` only if idle; defaults to draw but backends can overrride
Copy link
Member

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()
Copy link
Member

Choose a reason for hiding this comment

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

Could we add aplt.ioff() call in thecleanup decorator?

@tacaswelltacaswell added this to the2.1 (next point release) milestoneJan 3, 2017
@tacaswell
Copy link
Member

I have been thinking about this a bit more recently and coming around todraw_idle should be a no-op for non-interactive backends.

If it is better to make this a no-op here and require that the sub-classes that want to provide itdo or to leave this as-is and make the backends thatdo not want to provide it to over-ride with a no-op is not clear to me yet.

@tacaswelltacaswell modified the milestones:2.1 (next point release),2.2 (next next feature release)Aug 29, 2017
@jklymak
Copy link
Member

This is very stale. I can't tell if this is a good idea or not...

@dopplershift
Copy link
Contributor

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

@efiring
Copy link
Member

The change in backend_bases looks good, and long overdue, though I haven't actually tried it and might be missing something.
I think@jkseppan's suggestion to addplt.ioff() tocleanup is good. Then the last test would not need a special internal function, just aplt.ion().

@efiringefiring modified the milestones:needs sorting,v3.4.0Jul 14, 2020
@tacaswell
Copy link
Member

We have made other changes to the tests that I think actually eliminate most of the changes to the tests.

@tacaswell
Copy link
Member

(bleeding) ~/s/p/matplotlib dont-double-draw↑·18365↓·3|⚑18 Just abit out of date.

@tacaswell
Copy link
Member

I think that this PR pre-dates the ability to push to contributor branches, I'll open a new one.

@tacaswelltacaswell mentioned this pull requestJul 14, 2020
6 tasks
@tacaswell
Copy link
Member

Closed in favor of#17923

@tacaswelltacaswell removed this from thev3.4.0 milestoneJul 14, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jkseppanjkseppanjkseppan left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

9 participants
@mdboom@tacaswell@WeatherGod@jklymak@dopplershift@efiring@jkseppan@QuLogic@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp