Skip to content

Commit 5c1f9fb

Browse files
committed
deal with end of iteration cleanly
1 parent 4159539 commit 5c1f9fb

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎spatialmath/base/animate.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ def run(self, movie=None, axes=None, repeat=False, interval=50, nframes=100, pau
161161
def update(frame, animation):
162162
if self.trajectory is not None:
163163
# passed a trajectory as an iterator or generator, get next
164-
T = next(self.trajectory)
164+
try:
165+
T = next(self.trajectory)
166+
except StopIteration:
167+
animation.done = True
168+
return
165169
else:
166170
# passed a single transform, interpolate it
167171
T = base.trinterp(start=self.start, end=self.end, s=frame / nframes)
@@ -735,6 +739,9 @@ def plotvol2(dim, ax=None, equal=False):
735739
if ax is None:
736740
ax = plt.subplot()
737741
ax.axis(dims)
742+
ax.set_xlabel('X')
743+
ax.set_ylabel('Y')
744+
738745
if equal:
739746
ax.set_aspect('equal')
740747
return ax
@@ -765,6 +772,9 @@ def plotvol3(dim, ax=None, equal=False):
765772
ax.set_xlim3d(dims[0], dims[1])
766773
ax.set_ylim3d(dims[2], dims[3])
767774
ax.set_zlim3d(dims[4], dims[5])
775+
ax.set_xlabel('X')
776+
ax.set_ylabel('Y')
777+
ax.set_zlabel('Z')
768778

769779
if equal:
770780
ax.set_aspect('equal')

0 commit comments

Comments
 (0)