hey u mentioned that thr r several other fns tht helps to plot the animated grapgh other then funcanimation could u please name some coz funcanimation attribute is not responding in my system
Thanks for the nice tutorial! One issue though: I tried the code and got an error message: RuntimeError: The animation function must return a sequence of Artist objects. I had to add "return line," to the end of the animate(frame) function - then it works. Why does this not produce an error in your code?.
Update: this seems to have do with the Matplotlib backend. If I run the code without 'return line.' in a Jupyter Notebook, it works, but if I run it in Spyder on my Anaconda Python installation (with qt backend) it runs only if 'return line.' is added. Does anybody know why?
@@michaelk4602 try the following setup in Spyder: Preferences/IPython-Console/Graphics and set the Backend to automatic (it should be on 'Inline' by default). Plots and animations should pop up in the interactive mode in a new window without explicitly calling 'plt.show()' or 'return line' then.
I'd like for one process to receive data from the serial port, and then push that data into a queue so that matplotlib can update the figure real-time! However, FuncAnimation is not automatically calling the update function I've specified. animation.FuncAnimation(plt.gcf(), func=self.animate_fig(), interval=100, blit=True, repeat=True) The figure opens, but do you see anything that is preventing the call to "animate_fig"? I don't see the periodic "Update" print statement! from time import time, sleep from multiprocessing import Queue as mpQueue import matplotlib.pyplot as plt import matplotlib.animation as animation global ani #### Must be assigned to a global variable class PlotClass: # Create STATIC LOCAL instances accessible across class functions fig = None ax = None line1 = None q = None x_list_vec = [] y1_list_vec = [] def __init__(self, qdata ): # Save handle to Queue self.q = qdata # this is the call to matplotlib that allows dynamic plotting plt.ion() # Setup Figure with 'size' number of elements self.fig = plt.figure(figsize=(13,6)) self.ax = self.fig.add_subplot(111) # Create a list variable to the animation self.line1, = self.ax.plot(self.x_list_vec, self.y1_list_vec, marker = 'o', label='y1', color='r') # show a starting plot plt.xticks(rotation=45, ha='right') plt.title('Title: Hello World') plt.subplots_adjust(bottom=0.30) plt.show() def animate_fig(self, frame_num , user_arg1, user_arg2): #
I am getting an error on the line video = anim.to_html5_video() Can we do it without converting it to HTML5, like a normal plot, I don't need to save it, I just need to run it and display