Найти - Пользователи
Полная версия: mathplot и очень много графиков
Начало » Python для новичков » mathplot и очень много графиков
1
Mazay_Ka
Всем привет
Вообщем ситуация следующая, рисую я графики с помощью mathplot, много порядка 11 тысяч, это графики посещаемости минутные и часовые. Ругается mathplot сначало говорит

C:\Python27\lib\site-packages\matplotlib\pyplot.py:424: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
max_open_warning, RuntimeWarning)

потом подвисает вылетает и пишет

Fail to allocate bitmap


This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
tried to delete photo image when instances still exist

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Что посоветуете как быть??

вот код функции которая рисует

def paint_all(self, dir):       
        dir = dir
        self.count_cord()
        dir = os.path.join(dir)
        if not os.path.isdir(dir):
            os.makedirs(dir)
        #Paint Mins Graf
        t_min = self.all_min_count.keys()
        s_min = self.all_min_count.values()
        #grid(True)
        figure() 
        plot(t_min, s_min)
        savefig(os.path.join(dir, "all_mins.png"))
        #Paint Hours Graf
        t_hour = self.all_hour_count.keys()
        s_hour = self.all_hour_count.values()
        #grid(True)
        figure()
        plot(t_hour, s_hour)
        savefig(os.path.join(dir, "all_hours.png"))        
        #Paint Id mins
        for tid in self.tid_min_count.keys():
            t_min = self.tid_min_count[tid].keys()
            s_min = self.tid_min_count[tid].values()
            grid(True)
            figure()
            plot(t_min, s_min)
            savefig(os.path.join(dir, str(tid)+"_min.png"))
        #Paint id hours            
        for tid in self.tid_hour_count.keys():
            t_hour = self.tid_hour_count[tid].keys()
            s_hour = self.tid_hour_count[tid].values()
            grid(True)
            figure()
            plot(t_hour, s_hour)
            savefig(os.path.join(dir, str(tid)+"_hour.png"))

Рисует не больше 500 штук
а надо 10 к
py.user.next
Mazay_Ka
More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed
Надо поискать, как закрывать графики, чтобы они память не занимали. Как график нарисовал, надо ресурсы освободить.
Alen
matplotlib освобождает память при вызове метода show(), но поскольку вам этого не нужно, решение тут: http://stackoverflow.com/questions/7101404/how-can-i-release-memory-after-creating-matplotlib-figures
и тут: http://stackoverflow.com/questions/7125710/matplotlib-errors-result-in-a-memory-leak-how-can-i-free-up-that-memory
Mazay_Ka
Спасибо
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB