Уведомления

Группа в Telegram: @pythonsu

#1 Янв. 9, 2015 02:57:10

Mazay_Ka
Зарегистрирован: 2013-04-03
Сообщения: 59
Репутация: +  0  -
Профиль   Отправить e-mail  

mathplot и очень много графиков

Всем привет
Вообщем ситуация следующая, рисую я графики с помощью 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 к

Офлайн

#2 Янв. 9, 2015 04:26:44

py.user.next
От:
Зарегистрирован: 2010-04-29
Сообщения: 10015
Репутация: +  857  -
Профиль   Отправить e-mail  

mathplot и очень много графиков

Mazay_Ka
More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed
Надо поискать, как закрывать графики, чтобы они память не занимали. Как график нарисовал, надо ресурсы освободить.



Отредактировано py.user.next (Янв. 9, 2015 04:28:01)

Офлайн

#3 Янв. 9, 2015 07:08:26

Alen
Зарегистрирован: 2013-08-01
Сообщения: 373
Репутация: +  49  -
Профиль   Отправить e-mail  

mathplot и очень много графиков

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

Отредактировано Alen (Янв. 9, 2015 07:11:10)

Офлайн

#4 Янв. 10, 2015 00:21:01

Mazay_Ka
Зарегистрирован: 2013-04-03
Сообщения: 59
Репутация: +  0  -
Профиль   Отправить e-mail  

mathplot и очень много графиков

Спасибо

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version