def _get_axes(self,fig):
# TODO is attaching these to the figure a good idea? why not save them
# here and reuse them if we recognize the figure being passed in
sz = self._fig_sz
if hasattr(fig,'_feature_ax') and hasattr(fig,'_stateseq_axs'):
return fig._feature_ax, fig._stateseq_axs
else:
if len(self.states_list) <= 2:
gs = GridSpec(sz+len(self.states_list),1)
feature_ax = plt.subplot(gs[:sz,:])
stateseq_axs = [plt.subplot(gs[sz+idx]) for idx in range(len(self.states_list))]
else:
gs = GridSpec(1,2)
sgs = GridSpecFromSubplotSpec(len(self.states_list),1,subplot_spec=gs[1])
feature_ax = plt.subplot(gs[0])
stateseq_axs = [plt.subplot(sgs[idx]) for idx in range(len(self.states_list))]
for ax in stateseq_axs:
ax.grid('off')
fig._feature_ax, fig._stateseq_axs = feature_ax, stateseq_axs
return feature_ax, stateseq_axs
评论列表
文章目录