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

Skip to content

Conversation

@jdh2358
Copy link
Collaborator

@jdh2358 jdh2358 commented Oct 15, 2011

Filter out figure artists where animated property is set before figure draw.

@WeatherGod
Copy link
Member

I want @rmay opinion on this. I would also like a chance to investigate the implications of this filtering. I have recently had issues with setting animated=True for objects. While they would display for show(), they wouldn't display on saving. There are also issues with blitting as well that I wonder could be addressed by this.

@jdh2358
Copy link
Collaborator Author

jdh2358 commented Oct 15, 2011

I believe the savefig issue is unrelated to this pull request. What we are addressing here is that a container artist like Figure or Axes should not ask their child artists to draw if the animated property is set, since that property is intentionally set to exclude an artist when drawing "the background", usually the figure and axes rectangles, the ticks, etc... This patch just makes the Figure act like the Axes, which I believe is correct.

The savefig issue should be addressed separately. One could simply store the animated state before saving (as we do with dpi and facecolor of the figure rectangle) and then restore after saving. It could be that someone is relying on the current behavior, in which case we would need a kwarg, but more likely this is just a wart and we should draw everything when saving. Eg in backend_bases.FigureCanvasBase.print_figure:

animated = dict()
for o in self.figure.findobj():
    animated[o] = o.get_animated()
    o.set_animated(False)

# now save the figure 

# now reset the animated state
for o, b in animated.items():
    o.set_animated(b)

Also, Ryan's animation API doesn't use or rely on the animated property as nearly as I can tell, so it lives outside this framework. He has a comment wondering if the two could be better integrated... To save a single frame when using Ryan's API, it should be enough to do, eg for the double pendulum demo:

# save a single frame as PNG; set the frame number before saving
animate(10)
fig.savefig('animated.png')

@WeatherGod
Copy link
Member

I agree, I just want to test some of these warts so that we don't have problems mysteriously disappearing further down the line and not know what solved it. Also it is @dopplershift (rmay was his SF account...).

@dopplershift
Copy link
Contributor

I don't see a problem with it. The new framework I made does not use the animated keyword...yet. At some point it probably should so that some things work more automatically.

*Ryan adds another item to "list of things to do when dissertation out of way"

jdh2358 added a commit that referenced this pull request Oct 18, 2011
@jdh2358 jdh2358 merged commit 37e492e into matplotlib:v1.1.x Oct 18, 2011
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.

3 participants