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
评论列表
文章目录