What are you plotting? How big is this list that the loops are taking
appreciable amounts of time?!?  Are we talking seconds here or ms?

Have you done enough profiling to know exactly which line in here are
slow?  I don't quite understand the `np.ravel` calls.

You might do better either with one (or many?) collection artists.

You might also look into just updating the artists you have.

Without some context of what these patches are it is really hard to help
(or even really understand why this is slow).

Tom

On Sat, May 16, 2015 at 6:44 PM bmer <bhmerch...@gmail.com> wrote:

> This is what my animation function (i.e. the one that gets called by
> `FuncAnimation`) looks like:
>
>         import numpy as np
>         ...
>         def mpl_animation_function(n):
>             print "animating timestep: ", n
>
>             if n > 0:
>                 previous_relevant_patch_indices =
> np.ravel(patch_indices_per_timestep[n-1])
>                 for index in previous_relevant_patch_indices:
>                     (patches[index]).set_visible(False)
>
>             relevant_patch_indices =
> np.ravel(patch_indices_per_timestep[n])
>
>             for index in relevant_patch_indices:
>                 (patches[index]).set_visible(True)
>
>             return patches,
>
> `patches` is a pre-generated list of patches (possibly large), that have
> already been added to an `axes` instance.
>
>
> This function is awfully time-consuming as the number of patches becomes
> large.
>
> One idea I had was to parallelize the `for` loop, but likely that won't
> work
> because of issues with the `axes` instance being accessed and modified in
> parallel -- so I am afraid of fruitlessly spending time there. Do I have
> any
> other options, or is parallelization possible?
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/What-are-my-options-for-speeding-up-a-custom-function-called-by-FuncAnimation-tp45562.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to