On Thu, Jul 5, 2012 at 1:55 PM, Gökhan Sever <gokhanse...@gmail.com> wrote:
> And you might get back more memory if you didn't have to have all the data
>> in memory at once, but that may or may not help you. The only other
>> suggestion I can make is to attempt to eliminate the overhead in the inner
>> loop. Essentially, I would try making a single figure and a single
>> AxesGrid object (before the outer loop). Then go over each subplot in the
>> AxesGrid object and set the limits, the log scale, the ticks and the tick
>> locater (I wouldn't be surprised if that is eating up cpu cycles). All of
>> this would be done once before the loop you have right now. Then create
>> the PdfPages object, and loop over all of the plots you have, essentially
>> recycling the figure and AxesGrid object.
>>
>> At end of the outer loop, instead of closing the figure, you should call
>> "remove()" for each plot element you made. Essentially, as you loop over
>> the inner loop, save the output of the plot() call to a list, and then when
>> done with those plots, pop each element of that list and call "remove()" to
>> take it out of the subplot. This will let the subplot axes retain the
>> properties you set earlier.
>>
>> I hope that made sense.
>> Ben Root
>>
>>
> Hi Ben,
>
> I should have data the available at once, as I directly read that array
> from a netcdf file. The memory requirement for my data is small comparing
> to overhead added once plot creation is started. Fabrice's reply includes
> most of what you describe except the remove call part. These changes made
> big impact to lower my execution times. Thank you again for your
> explanation.
>
>
> --
> Gökhan
>
Actually, looking at Fabrice's code, you might be able to get it to be
slightly faster. Lines 39-41 should be protected by a "if i == 0"
statement because it only needs to be done once. Furthermore, you might
get some more improvements if you allow the subplots to share_all, in which
case, you only need to set the limits and maybe the scale and the locator
once.
Cheers!
Ben Root
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users