def showDomain(self, a=0, s=None): """ shows a live graph of each observable dimension """ # only update the graph every couple of steps, otherwise it is # extremely slow if self.t % self.show_domain_every != 0 and not self.t >= self.episodeCap: return n = self.state_space_dims + 1 names = list(self.state_names) + ["Action"] colors = ["m", "c", "b", "r", "g", "k"] handles = getattr(self, "_state_graph_handles", None) plt.figure("Domain", figsize=(12, 10)) if handles is None: handles = [] f, axes = plt.subplots( n, sharex=True, num="Domain", figsize=(12, 10)) f.subplots_adjust(hspace=0.1) for i in range(n): ax = axes[i] d = np.arange(self.episodeCap + 1) * 5 ax.set_ylabel(names[i]) ax.locator_params(tight=True, nbins=4) handles.append( ax.plot(d, self.episode_data[i], color=colors[i])[0]) self._state_graph_handles = handles ax.set_xlabel("Days") for i in range(n): handles[i].set_ydata(self.episode_data[i]) ax = handles[i].axes ax.relim() ax.autoscale_view() plt.figure("Domain").canvas.draw() plt.figure("Domain").canvas.flush_events()
def showDomain(self, a=0, s=None): """ shows a live graph of each concentration """ # only update the graph every couple of steps, otherwise it is # extremely slow if self.t % self.show_domain_every != 0 and not self.t >= self.episodeCap: return n = self.state_space_dims + 1 names = list(self.state_names) + ["Action"] colors = ["b", "b", "b", "b", "r", "g", "k"] handles = getattr(self, "_state_graph_handles", None) plt.figure("Domain", figsize=(12, 10)) if handles is None: handles = [] f, axes = plt.subplots( n, sharex=True, num="Domain", figsize=(12, 10)) f.subplots_adjust(hspace=0.1) for i in range(n): ax = axes[i] d = np.arange(self.episodeCap + 1) * 5 ax.set_ylabel(names[i]) ax.locator_params(tight=True, nbins=4) handles.append( ax.plot(d, self.episode_data[i], color=colors[i])[0]) self._state_graph_handles = handles ax.set_xlabel("Days") for i in range(n): handles[i].set_ydata(self.episode_data[i]) ax = handles[i].axes ax.relim() ax.autoscale_view() plt.figure("Domain").canvas.draw() plt.figure("Domain").canvas.flush_events()