def _plot_valfun(self, VMat): """ :returns: handle to the figure .. warning:: The calling function MUST call pl.draw() or the figures will not be updated. """ if self.valueFunction_fig is None or self.valueFunction_img is None: maxV = VMat.max() minV = VMat.min() self.valueFunction_fig = pl.figure("Value Function") ax = self.valueFunction_fig.add_subplot(111) self.valueFunction_img = ax.imshow( VMat, cmap='ValueFunction', interpolation='nearest', origin='lower', vmin=minV, vmax=maxV) pl.xticks(self.xTicks, self.xTicksLabels, fontsize=12) # Don't need the y labels since we share axes on subplot pl.xlabel(r"$\theta$ (degree)") pl.title('Value Function') norm = colors.Normalize(vmin=VMat.min(), vmax=VMat.max()) self.valueFunction_img.set_data(VMat) self.valueFunction_img.set_norm(norm) self.valueFunction_fig.canvas.draw()
def _plot_policy(self, piMat): """ :returns: handle to the figure .. warning:: The calling function MUST call pl.draw() or the figures will not be updated. """ if self.policy_fig is None or self.policy_img is None: self.policy_fig = pl.figure("Policy") ax = self.policy_fig.add_subplot(111) self.policy_img = ax.imshow( piMat, cmap='InvertedPendulumActions', interpolation='nearest', origin='lower', vmin=0, vmax=self.actions_num) pl.xticks(self.xTicks, self.xTicksLabels, fontsize=12) pl.yticks(self.yTicks, self.yTicksLabels, fontsize=12) pl.xlabel(r"$\theta$ (degree)") pl.ylabel(r"$\dot{\theta}$ (degree/sec)") pl.title('Policy') self.policy_img.set_data(piMat) self.policy_fig.canvas.draw()