SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Hjalmar T. <htu...@gm...> - 2016年10月07日 20:48:11
Hi all,
I made a little video player using matplotlib. I need it to allow very good
control over the playback speed (e.g. direction, frame-by-frame stepping
and fast and slow).
However, it's not very fast. Max frame rate I can achieve is 10-20 fps.
I followed Basti's advice on speeding up plotting (
http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
This resulted in a more than 2x improvement (from <5 to 10-20 fps), but I
would like to reach 40-50 fps.
The core code is something like this:
self.im.set_data(self.video_frame)
self.text.set_text('some text')
 self.ax.draw_artist(self.im)
 self.ax.draw_artist(self.text)
 self.im.figure.canvas.update()
 self.im.figure.canvas.flush_events()
video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50, but
the improvement is marginal.
I saw that Harden (
http://www.swharden.com/wp/2013-04-15-fixing-slow-matplotlib-in-pythonxy/)
recommended using TkAgg over Qt4Agg since TkAgg is supposed to be faster.
But, TkAgg doesn't play nicely with figure.canvas.update(). I get the
following error:
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update'
It works with Qt4Agg though.
Does anyone have a fix for this? Or some general advice on how to speed up
playback speed?
I tried with both matplotlib 1.5.1 and the current version from
github 2.0.0b4+2373.gb34c55d
Best regards,
Hjalmar
From: Thomas C. <tca...@gm...> - 2016年10月14日 14:37:45
Instead of `canvas.update` call `self.im.figure.canvas.draw_idle()`.
IIRC `update` is part of the API inherited from Qt, not part of the API we
ensure that all of the canvas objects have.
Tom
On Fri, Oct 7, 2016 at 4:48 PM Hjalmar Turesson <htu...@gm...> wrote:
> Hi all,
>
>
> I made a little video player using matplotlib. I need it to allow very
> good control over the playback speed (e.g. direction, frame-by-frame
> stepping and fast and slow).
>
> However, it's not very fast. Max frame rate I can achieve is 10-20 fps.
> I followed Basti's advice on speeding up plotting (
> http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
> This resulted in a more than 2x improvement (from <5 to 10-20 fps), but I
> would like to reach 40-50 fps.
>
> The core code is something like this:
>
> self.im.set_data(self.video_frame)
>
> self.text.set_text('some text')
>
> self.ax.draw_artist(self.im)
> self.ax.draw_artist(self.text)
> self.im.figure.canvas.update()
> self.im.figure.canvas.flush_events()
>
> video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50,
> but the improvement is marginal.
>
> I saw that Harden (
> http://www.swharden.com/wp/2013-04-15-fixing-slow-matplotlib-in-pythonxy/)
> recommended using TkAgg over Qt4Agg since TkAgg is supposed to be faster.
> But, TkAgg doesn't play nicely with figure.canvas.update(). I get the
> following error:
> AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update'
> It works with Qt4Agg though.
>
> Does anyone have a fix for this? Or some general advice on how to speed up
> playback speed?
>
> I tried with both matplotlib 1.5.1 and the current version from
> github 2.0.0b4+2373.gb34c55d
>
> Best regards,
> Hjalmar
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Hjalmar T. <htu...@gm...> - 2016年10月14日 21:29:26
That works fine. And it explains why update() only worked with the Qt
backends (I tried all). The speed is still not super impressive though (~20
fps), but I think I will just start skipping frames when playing at above
20 fps.
Thanks,
Hjalmar
On Fri, Oct 14, 2016 at 10:37 AM, Thomas Caswell <tca...@gm...> wrote:
> Instead of `canvas.update` call `self.im.figure.canvas.draw_idle()`.
>
> IIRC `update` is part of the API inherited from Qt, not part of the API we
> ensure that all of the canvas objects have.
>
> Tom
>
> On Fri, Oct 7, 2016 at 4:48 PM Hjalmar Turesson <htu...@gm...>
> wrote:
>
>> Hi all,
>>
>>
>> I made a little video player using matplotlib. I need it to allow very
>> good control over the playback speed (e.g. direction, frame-by-frame
>> stepping and fast and slow).
>>
>> However, it's not very fast. Max frame rate I can achieve is 10-20 fps.
>> I followed Basti's advice on speeding up plotting (
>> http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
>> This resulted in a more than 2x improvement (from <5 to 10-20 fps), but I
>> would like to reach 40-50 fps.
>>
>> The core code is something like this:
>>
>> self.im.set_data(self.video_frame)
>>
>> self.text.set_text('some text')
>>
>> self.ax.draw_artist(self.im)
>> self.ax.draw_artist(self.text)
>> self.im.figure.canvas.update()
>> self.im.figure.canvas.flush_events()
>>
>> video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50,
>> but the improvement is marginal.
>>
>> I saw that Harden (http://www.swharden.com/wp/2013-04-15-fixing-slow-
>> matplotlib-in-pythonxy/) recommended using TkAgg over Qt4Agg since TkAgg
>> is supposed to be faster.
>> But, TkAgg doesn't play nicely with figure.canvas.update(). I get the
>> following error:
>> AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update'
>> It works with Qt4Agg though.
>>
>> Does anyone have a fix for this? Or some general advice on how to speed
>> up playback speed?
>>
>> I tried with both matplotlib 1.5.1 and the current version from
>> github 2.0.0b4+2373.gb34c55d
>>
>> Best regards,
>> Hjalmar
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot______
>> _________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
From: Thomas C. <tca...@gm...> - 2017年01月07日 20:36:39
To push much past 20Hz you will want to look into blitting. See
http://matplotlib.org/devdocs/api/animation_api.html for a rough
introduction on how to use blitting (and see the animation code for an
example of handling all of the corner cases).
Tom
On Fri, Oct 14, 2016 at 5:29 PM Hjalmar Turesson <htu...@gm...>
wrote:
> That works fine. And it explains why update() only worked with the Qt
> backends (I tried all). The speed is still not super impressive though (~20
> fps), but I think I will just start skipping frames when playing at above
> 20 fps.
>
> Thanks,
> Hjalmar
>
> On Fri, Oct 14, 2016 at 10:37 AM, Thomas Caswell <tca...@gm...>
> wrote:
>
> Instead of `canvas.update` call `self.im.figure.canvas.draw_idle()`.
>
> IIRC `update` is part of the API inherited from Qt, not part of the API we
> ensure that all of the canvas objects have.
>
> Tom
>
> On Fri, Oct 7, 2016 at 4:48 PM Hjalmar Turesson <htu...@gm...>
> wrote:
>
> Hi all,
>
>
> I made a little video player using matplotlib. I need it to allow very
> good control over the playback speed (e.g. direction, frame-by-frame
> stepping and fast and slow).
>
> However, it's not very fast. Max frame rate I can achieve is 10-20 fps.
> I followed Basti's advice on speeding up plotting (
> http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
> This resulted in a more than 2x improvement (from <5 to 10-20 fps), but I
> would like to reach 40-50 fps.
>
> The core code is something like this:
>
> self.im.set_data(self.video_frame)
>
> self.text.set_text('some text')
>
> self.ax.draw_artist(self.im)
> self.ax.draw_artist(self.text)
> self.im.figure.canvas.update()
> self.im.figure.canvas.flush_events()
>
> video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50,
> but the improvement is marginal.
>
> I saw that Harden (
> http://www.swharden.com/wp/2013-04-15-fixing-slow-matplotlib-in-pythonxy/)
> recommended using TkAgg over Qt4Agg since TkAgg is supposed to be faster.
> But, TkAgg doesn't play nicely with figure.canvas.update(). I get the
> following error:
> AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update'
> It works with Qt4Agg though.
>
> Does anyone have a fix for this? Or some general advice on how to speed up
> playback speed?
>
> I tried with both matplotlib 1.5.1 and the current version from
> github 2.0.0b4+2373.gb34c55d
>
> Best regards,
> Hjalmar
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
From: Hjalmar T. <htu...@gm...> - 2017年04月18日 20:50:40
Thanks for the help (and sorry for the super-late reply).
I just tried blitting, but it doesn't really help. I cannot exceed 20 fps.
The problem is that I'm plotting data from a video file, so that for each
frame I need to draw a new array (not just a foreground). I think its just
to much data.
Thanks,
Hjalmar
On Sat, Jan 7, 2017 at 3:36 PM, Thomas Caswell <tca...@gm...> wrote:
> To push much past 20Hz you will want to look into blitting. See
> http://matplotlib.org/devdocs/api/animation_api.html for a rough
> introduction on how to use blitting (and see the animation code for an
> example of handling all of the corner cases).
>
> Tom
>
> On Fri, Oct 14, 2016 at 5:29 PM Hjalmar Turesson <htu...@gm...>
> wrote:
>
>> That works fine. And it explains why update() only worked with the Qt
>> backends (I tried all). The speed is still not super impressive though (~20
>> fps), but I think I will just start skipping frames when playing at above
>> 20 fps.
>>
>> Thanks,
>> Hjalmar
>>
>> On Fri, Oct 14, 2016 at 10:37 AM, Thomas Caswell <tca...@gm...>
>> wrote:
>>
>> Instead of `canvas.update` call `self.im.figure.canvas.draw_idle()`.
>>
>> IIRC `update` is part of the API inherited from Qt, not part of the API
>> we ensure that all of the canvas objects have.
>>
>> Tom
>>
>> On Fri, Oct 7, 2016 at 4:48 PM Hjalmar Turesson <htu...@gm...>
>> wrote:
>>
>> Hi all,
>>
>>
>> I made a little video player using matplotlib. I need it to allow very
>> good control over the playback speed (e.g. direction, frame-by-frame
>> stepping and fast and slow).
>>
>> However, it's not very fast. Max frame rate I can achieve is 10-20 fps.
>> I followed Basti's advice on speeding up plotting (
>> http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
>> This resulted in a more than 2x improvement (from <5 to 10-20 fps), but I
>> would like to reach 40-50 fps.
>>
>> The core code is something like this:
>>
>> self.im.set_data(self.video_frame)
>>
>> self.text.set_text('some text')
>>
>> self.ax.draw_artist(self.im)
>> self.ax.draw_artist(self.text)
>> self.im.figure.canvas.update()
>> self.im.figure.canvas.flush_events()
>>
>> video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50,
>> but the improvement is marginal.
>>
>> I saw that Harden (http://www.swharden.com/wp/2013-04-15-fixing-slow-
>> matplotlib-in-pythonxy/) recommended using TkAgg over Qt4Agg since TkAgg
>> is supposed to be faster.
>> But, TkAgg doesn't play nicely with figure.canvas.update(). I get the
>> following error:
>> AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update'
>> It works with Qt4Agg though.
>>
>> Does anyone have a fix for this? Or some general advice on how to speed
>> up playback speed?
>>
>> I tried with both matplotlib 1.5.1 and the current version from
>> github 2.0.0b4+2373.gb34c55d
>>
>> Best regards,
>> Hjalmar
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot______
>> _________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
From: Benjamin R. <ben...@gm...> - 2017年04月18日 21:05:56
I am wondering if the "optimizations" you have are actually slowing you
down. I have never found myself needing to flush_events() or call update()
like that. Or to draw the artists like you are doing. Without seeing more
of the code, it is hard to judge. Have you tried using "runsnakerun" to
profile your code to find out what is actually slowing it down? I can get
60-70Hz without even trying for 3d plotting animations, and that is
probably more computation than this.
On Tue, Apr 18, 2017 at 4:50 PM, Hjalmar Turesson <htu...@gm...>
wrote:
> Thanks for the help (and sorry for the super-late reply).
>
> I just tried blitting, but it doesn't really help. I cannot exceed 20 fps.
> The problem is that I'm plotting data from a video file, so that for each
> frame I need to draw a new array (not just a foreground). I think its just
> to much data.
>
> Thanks,
> Hjalmar
>
> On Sat, Jan 7, 2017 at 3:36 PM, Thomas Caswell <tca...@gm...> wrote:
>
>> To push much past 20Hz you will want to look into blitting. See
>> http://matplotlib.org/devdocs/api/animation_api.html for a rough
>> introduction on how to use blitting (and see the animation code for an
>> example of handling all of the corner cases).
>>
>> Tom
>>
>> On Fri, Oct 14, 2016 at 5:29 PM Hjalmar Turesson <htu...@gm...>
>> wrote:
>>
>>> That works fine. And it explains why update() only worked with the Qt
>>> backends (I tried all). The speed is still not super impressive though (~20
>>> fps), but I think I will just start skipping frames when playing at above
>>> 20 fps.
>>>
>>> Thanks,
>>> Hjalmar
>>>
>>> On Fri, Oct 14, 2016 at 10:37 AM, Thomas Caswell <tca...@gm...>
>>> wrote:
>>>
>>> Instead of `canvas.update` call `self.im.figure.canvas.draw_idle()`.
>>>
>>> IIRC `update` is part of the API inherited from Qt, not part of the API
>>> we ensure that all of the canvas objects have.
>>>
>>> Tom
>>>
>>> On Fri, Oct 7, 2016 at 4:48 PM Hjalmar Turesson <htu...@gm...>
>>> wrote:
>>>
>>> Hi all,
>>>
>>>
>>> I made a little video player using matplotlib. I need it to allow very
>>> good control over the playback speed (e.g. direction, frame-by-frame
>>> stepping and fast and slow).
>>>
>>> However, it's not very fast. Max frame rate I can achieve is 10-20 fps.
>>> I followed Basti's advice on speeding up plotting (
>>> http://bastibe.de/2013-05-30-speeding-up-matplotlib.html).
>>> This resulted in a more than 2x improvement (from <5 to 10-20 fps), but
>>> I would like to reach 40-50 fps.
>>>
>>> The core code is something like this:
>>>
>>> self.im.set_data(self.video_frame)
>>>
>>> self.text.set_text('some text')
>>>
>>> self.ax.draw_artist(self.im)
>>> self.ax.draw_artist(self.text)
>>> self.im.figure.canvas.update()
>>> self.im.figure.canvas.flush_events()
>>>
>>> video_frame is a 200 x 250 array. I tried lowering dpi from 100 to 50,
>>> but the improvement is marginal.
>>>
>>> I saw that Harden (http://www.swharden.com/wp/20
>>> 13-04-15-fixing-slow-matplotlib-in-pythonxy/) recommended using TkAgg
>>> over Qt4Agg since TkAgg is supposed to be faster.
>>> But, TkAgg doesn't play nicely with figure.canvas.update(). I get the
>>> following error:
>>> AttributeError: 'FigureCanvasTkAgg' object has no attribute 'update'
>>> It works with Qt4Agg though.
>>>
>>> Does anyone have a fix for this? Or some general advice on how to speed
>>> up playback speed?
>>>
>>> I tried with both matplotlib 1.5.1 and the current version from
>>> github 2.0.0b4+2373.gb34c55d
>>>
>>> Best regards,
>>> Hjalmar
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot______
>>> _________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /