utils.py 文件源码

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

项目:nelpy 作者: nelpy 项目源码 文件源码
def __enter__(self):
        if not self.skip:
            self.fig = plt.figure(figsize=self.figsize,
                                  dpi=self.dpi,
                                  **self.kwargs)
            self.fig.npl_gs = gridspec.GridSpec(nrows=self.nrows,
                                                ncols=self.ncols)

            self.ax = np.array([self.fig.add_subplot(ss) for ss in self.fig.npl_gs])
            # self.fig, self.ax = plt.subplots(nrows=self.nrows,
            #                                  ncols=self.ncols,
            #                                  figsize=self.figsize,
            #                                  tight_layout=self.tight_layout,
            #                                  dpi=self.dpi,
            #                                  **self.kwargs)
            if len(self.ax) == 1:
                self.ax = self.ax[0]

            if self.tight_layout:
                self.fig.npl_gs.tight_layout(self.fig)

            # gs1.tight_layout(fig, rect=[0, 0.03, 1, 0.95])
            if self.fig != plt.gcf():
                self.clear()
                raise RuntimeError('Figure does not match active mpl figure')
            return self.fig, self.ax
        return -1, -1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号