3

I am trying to update plot every iteration. I got a great answer here and shown below:

self.point, = plt.plot([],[], 'o', color='green')
self.line, =  plt.plot([],[], ls="-", color='red', lw=2)
plt.show(block=False)
self.plot_pose()

def plot_pose(self):
    self.point.set_data(self.pose[0], self.pose[1])
    self.line.set_data([self.pose[0], self.pose[0] - 0.5*np.cos(self.pose[2])],
                       [self.pose[1], self.pose[1] + 0.5*np.sin(self.pose[2])])

    plt.pause(0.0001)

Unfortunately, when I run this on jupyter notebook, it doesn't update the plot, even with the %matplotlib inline. Any suggestions on how to get this to work on jupyter-notebook?

MoneyBall
  • 2,343
  • 5
  • 26
  • 59
  • `inline` produces png images. Those are of course static, not animated. Hence `plt.pause()` cannot be used with the inline backend. For an example for using the `%matplotlib notebook` backend, see [this question](https://stackoverflow.com/questions/43663613/dynamic-plot-works-in-idle-but-not-jupyter-notebook). A list of possible options to create animations in jupyter can be found in [this question](https://stackoverflow.com/questions/35532498/animation-in-ipython-notebook). – ImportanceOfBeingErnest Jan 13 '18 at 13:50

0 Answers0