animation in thread

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

animation in thread

arash
This post has NOT been accepted by the mailing list yet.
I am new to matplotlib and I am trying to get started with animation library. There is an example here for a simple strip chart: https://matplotlib.org/examples/animation/strip_chart_demo.html I tried to use this example in a thread. I created a simple threading.Thread class, and in it's run() method, called: ani = animation.FuncAnimation(fig, scope.update, emitter, interval=10,True) plt.show() here is class: class graph(threading.Thread): def __init__(self, feeder): threading.Thread.__init__(self) self.fig, self.ax = plt.subplots() self.scope = Scope(self.ax) self.feeder=feeder self.running=True def run(self): while self.running: ani = animation.FuncAnimation(self.fig, self.scope.update, self.feeder.emit_ch1(), interval=1, blit=True) plt.show() but when I start this thread, it never shows the windows. Isn't this right usage?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: animation in thread

arash
This post has NOT been accepted by the mailing list yet.
(Resending to correct formatting)

I am new to matplotlib and I am trying to get started with animation library.
There is an example here for a simple strip chart:

https://matplotlib.org/examples/animation/strip_chart_demo.html

I tried to use this example in a thread. I created a simple threading.Thread class, and in it's run() method, called:

ani = animation.FuncAnimation(fig, scope.update, emitter, interval=10,True)
plt.show()


here is class:


import matplotlib.pyplot as plt
import matplotlib.animation as animation

class graph(threading.Thread):

    def __init__(self, feeder):
        threading.Thread.__init__(self)
        self.fig, self.ax = plt.subplots()
        self.scope = Scope(self.ax)
        self.feeder=feeder
        self.running=True

    def run(self):
        while self.running:
            ani = animation.FuncAnimation(self.fig, self.scope.update, self.feeder.emit_ch1(), interval=1, blit=True)
            plt.show()
           
but when I start this thread, it never shows the windows. Isn't this right usage?
Loading...