Skip to content

Commit

Permalink
defer import of matplotlib.animation in pyplot_visualizer (#18324)
Browse files Browse the repository at this point in the history
  • Loading branch information
trowell-tri authored Nov 15, 2022
1 parent bac9cf6 commit 333ede3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bindings/pydrake/systems/pyplot_visualizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import matplotlib
import matplotlib.animation as animation
import numpy as np
from warnings import warn

Expand Down Expand Up @@ -129,6 +128,9 @@ def _draw_recorded_frame(self, i):
return self.draw(self._recorded_contexts[i])

def get_recording_as_animation(self, **kwargs):
# We defer this import to this call site to prevent the import
# from hanging. See #18323.
import matplotlib.animation as animation
ani = animation.FuncAnimation(fig=self.fig,
func=self._draw_recorded_frame,
frames=len(self._recorded_contexts),
Expand Down Expand Up @@ -161,6 +163,9 @@ def animate(self, log, resample=True, **kwargs):
def animate_update(i):
self.draw(x[:, i])

# We defer this import to this call site to prevent the import
# from hanging. See #18323.
import matplotlib.animation as animation
ani = animation.FuncAnimation(fig=self.fig,
func=animate_update,
frames=t.shape[0],
Expand Down

0 comments on commit 333ede3

Please sign in to comment.