def __init__(self, fig, gs, num_plots, rows=None, cols=None):
if cols is None:
cols = int(np.floor(np.sqrt(num_plots)))
if rows is None:
rows = int(np.ceil(float(num_plots)/cols))
assert num_plots <= rows*cols, 'Too many plots to put into gridspec.'
self._fig = fig
self._gs = gridspec.GridSpecFromSubplotSpec(8, 1, subplot_spec=gs)
self._gs_legend = self._gs[0:1, 0]
self._gs_plot = self._gs[1:8, 0]
self._ax_legend = plt.subplot(self._gs_legend)
self._ax_legend.get_xaxis().set_visible(False)
self._ax_legend.get_yaxis().set_visible(False)
self._gs_plots = gridspec.GridSpecFromSubplotSpec(rows, cols, subplot_spec=self._gs_plot)
self._axarr = [plt.subplot(self._gs_plots[i], projection='3d') for i in range(num_plots)]
self._lims = [None for i in range(num_plots)]
self._plots = [[] for i in range(num_plots)]
for ax in self._axarr:
ax.tick_params(pad=0)
ax.locator_params(nbins=5)
for item in (ax.get_xticklabels() + ax.get_yticklabels() + ax.get_zticklabels()):
item.set_fontsize(10)
self._fig.canvas.draw()
self._fig.canvas.flush_events() # Fixes bug with Qt4Agg backend
评论列表
文章目录