animation in thread

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.htmlI 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?

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/animation-in-thread-tp48055.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170524/934a69b4/attachment-0001.html>

(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?

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/animation-in-thread-tp48055p48056.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

GUI frameworks tend to require they be on the main thread. Which backend /
gui framework are you using here?

In general you will have to arrange things so that the main thread owns the
GUI windows + plotting and the child threads own the computation.

Tom

···

On Sat, Aug 5, 2017 at 12:37 PM arash <azarmi at gmail.com> wrote:

(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?

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/animation-in-thread-tp48055p48056.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170805/0a598eb9/attachment.html>

main thread is owning the GUI. My Python installation runs Tkinter version
: 8.5 and this happens with Tkinter. I ran the same code on another machine
which used another GUI framework(not sure what was it) and it went well. So
I guess something is wrong with Tkinter.

···

On Sat, Aug 5, 2017 at 4:31 PM, Thomas Caswell <tcaswell at gmail.com> wrote:

GUI frameworks tend to require they be on the main thread. Which backend
/ gui framework are you using here?

In general you will have to arrange things so that the main thread owns
the GUI windows + plotting and the child threads own the computation.

Tom

On Sat, Aug 5, 2017 at 12:37 PM arash <azarmi at gmail.com> wrote:

(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?

--
View this message in context: http://matplotlib.1069221.n5.
nabble.com/animation-in-thread-tp48055p48056.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170807/6c385930/attachment-0001.html>