0

I am receiving new data every one second from a sensor in rasperry pi and appending the same in existing list. I want to dynamically update Bar chart every second as per the list. I am able to do that but it is taking more than a second. Please suggest how to resolve this issue. In my program I am keeping blit= False. Please help how can I turn on the blit with bar chart, so that plot recovery may get faster.

class PlotAnimate(): #threading.Thread
    def __init__(self):
        x_vals=[0,0,0,0,0,0,0,0,0]
        y_vals=[0,0,0,0,0,0,0,0,0]
        data= [x_vals, y_vals]
        ls_param=[0,19]
        index= count()
        self.fig= plt.figure(num =1,facecolor = "black")
        self.ax= self.fig.add_subplot(111)
        self.ax.set_facecolor("black")
        plt.axis('off')
        plt.tick_params(axis = "both", left = False, right = False, bottom = False, top =False)
        self.bar1 = FigureCanvasTkAgg(self.fig,root.t1.frame_chart)
        self.ani= FuncAnimation(self.fig, self.animate, blit= False,interval= 250)
        plt.tight_layout()
        self.bar1.get_tk_widget().pack(side=LEFT, fill=BOTH, expand = 1)

    def animate(self,i):
            #chart update
            index = []
            for j in range(root.t1.hist_size):#
                index.append(j)
            plt.tight_layout()
            self.ax.cla()
            plt.axis('off')
            plt.tick_params(axis = "both", left = False, right = False, bottom = False, top =False)
            self.ax.bar(index,root.t1.dose_list,color = root.t1.colors)#self.bar_dose,
1

1 Answer 1

0

The problem is that your FuncAnimation adds 250 ms to the time of receiving new data every one second. So, change it to be

 frames = 100
 self.ani= FuncAnimation(self.fig, self.animate, blit= True,frames=frames,
                              repeat=False,interval= 0)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.