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

Fixes to funcanimation#4800

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

Merged
tacaswell merged 4 commits intomatplotlib:masterfromjenshnielsen:funcanimfixes
Jul 31, 2015
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletionsexamples/animation/animate_decay.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,10 +10,17 @@ def data_gen(t=0):
t += 0.1
yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)


def init():
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 10)
del xdata[:]
del ydata[:]
line.set_data(xdata, ydata)
return line,

fig, ax = plt.subplots()
line, = ax.plot([], [], lw=2)
ax.set_ylim(-1.1, 1.1)
ax.set_xlim(0, 5)
ax.grid()
xdata, ydata = [], []

Expand All@@ -33,5 +40,5 @@ def run(data):
return line,

ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,
repeat=False)
repeat=False, init_func=init)
plt.show()
9 changes: 8 additions & 1 deletionlib/matplotlib/animation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -611,6 +611,7 @@ def _start(self, *args):
# actually start the event_source. We also disconnect _start
# from the draw_events
self.event_source.add_callback(self._step)
self._init_draw()
self.event_source.start()
self._fig.canvas.mpl_disconnect(self._first_draw_id)
self._first_draw_id = None # So we can check on save
Expand DownExpand Up@@ -760,6 +761,9 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
# since GUI widgets are gone. Either need to remove extra code to
# allow for this non-existant use case or find a way to make it work.
with writer.saving(self._fig, filename, dpi):
for anim in all_anim:
# Clear the initial frame
anim._init_draw()
for data in zip(*[a.new_saved_frame_seq()
for a in all_anim]):
for anim, d in zip(all_anim, data):
Expand DownExpand Up@@ -1080,7 +1084,10 @@ def new_saved_frame_seq(self):
# no saved frames, generate a new frame sequence and take the first
# save_count entries in it.
if self._save_seq:
return iter(self._save_seq)
# While iterating we are going to update _save_seq
# so make a copy to safely iterate over
self._old_saved_seq = self._save_seq.copy()
return iter(self._old_saved_seq)
else:
return itertools.islice(self.new_frame_seq(), self.save_count)

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp