recorder.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Theano-MPI 作者: uoguelph-mlrg 项目源码 文件源码
def plot_init(self, name, fig_specs=None, save=False):

        #add a figure with a single subplot

        if save==True:

            import matplotlib
            matplotlib.use('Agg') # non-interactive backend

        import matplotlib.pyplot as plt

        from matplotlib.font_manager import FontProperties

        fontP = FontProperties()
        fontP.set_size('small')
        self.colors = ['-r','-b','-m','-g']

        if self.fig==None:

            self.fig = plt.figure(figsize=(8,4))

            if fig_specs != None:
                # fig_spec is a dictionary of fig adjust specs
                self.fig.subplots_adjust(**fig_sepcs)

            else:

                self.fig.subplots_adjust(left = 0.15, bottom = 0.07,
                                    right = 0.94, top = 0.94,
                                    hspace = 0.14, wspace=0.20)

        if type(name) != str:
            raise TypeError('name should be a string')  

        layout = 'grid'
        n = len(self.fig.axes)

        if layout in ('h', 'horizontal'):
            n_rows, n_cols = (1, n+1)   
        elif layout in ('v', 'vertical'):
            n_rows, n_cols = (n+1, 1)  
        elif layout in ('g', 'grid'):
            vector_length=n+1
            n_cols = int(np.ceil(np.sqrt(vector_length)))
            n_rows = int(np.ceil(vector_length/n_cols))
        else:
            raise ValueError('Bad layout Value')

        for i in range(n):
            self.fig.axes[i].change_geometry(n_rows, n_cols, i+1)

        self.figsaxe[name] = self.fig.add_subplot(n_rows, n_cols, n+1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号