def _plot_valfun(self, VMat, xlim=None, ylim=None): """ :returns: handle to the figure """ plt.figure("Value Function") #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)") plt.title('Value Function') if xlim is not None and ylim is not None: extent = [xlim[0], xlim[1], ylim[0], ylim[1]] else: extent = [0, 1, 0, 1] self.valueFunction_fig = plt.imshow( VMat, cmap='ValueFunction', interpolation='nearest', origin='lower', extent=extent) norm = colors.Normalize(vmin=VMat.min(), vmax=VMat.max()) self.valueFunction_fig.set_data(VMat) self.valueFunction_fig.set_norm(norm) plt.draw()
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()