我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用pylab.set_cmap()。
def visualiseNormObject(self): shape = (2*self.extent, 2*self.extent) pylab.ion() pylab.clf() #pylab.set_cmap("bone") pylab.hot() pylab.title("image: %s" % self.fitsFile) pylab.imshow(np.reshape(self.signPreserveNorm(), shape, order="F"), interpolation="nearest") pylab.plot(np.arange(0,2*self.extent), self.extent*np.ones((2*self.extent,)), "r--") pylab.plot(self.extent*np.ones((2*self.extent,)), np.arange(0,2*self.extent), "r--") pylab.colorbar() pylab.ylim(-1, 2*self.extent) pylab.xlim(-1, 2*self.extent) pylab.xlabel("Pixels") pylab.ylabel("Pixels") pylab.show()
def saveBEVImageWithAxes(data, outputname, cmap = None, xlabel = 'x [m]', ylabel = 'z [m]', rangeX = [-10, 10], rangeXpx = None, numDeltaX = 5, rangeZ = [7, 62], rangeZpx = None, numDeltaZ = 5, fontSize = 16): ''' :param data: :param outputname: :param cmap: ''' aspect_ratio = float(data.shape[1])/data.shape[0] fig = pylab.figure() Scale = 8 # add +1 to get axis text fig.set_size_inches(Scale*aspect_ratio+1,Scale*1) ax = pylab.gca() #ax.set_axis_off() #fig.add_axes(ax) if cmap != None: pylab.set_cmap(cmap) #ax.imshow(data, interpolation='nearest', aspect = 'normal') ax.imshow(data, interpolation='nearest') if rangeXpx == None: rangeXpx = (0, data.shape[1]) if rangeZpx == None: rangeZpx = (0, data.shape[0]) modBev_plot(ax, rangeX, rangeXpx, numDeltaX, rangeZ, rangeZpx, numDeltaZ, fontSize, xlabel = xlabel, ylabel = ylabel) #plt.savefig(outputname, bbox_inches='tight', dpi = dpi) pylab.savefig(outputname, dpi = data.shape[0]/Scale) pylab.close() fig.clear()
def visualiseObject(self, cmap="hot"): pylab.ion() #pylab.set_cmap("gray") pylab.gray() pylab.title("image: %s" % self.fitsFile) pylab.imshow(self.getObject(), interpolation="nearest", cmap=cmap) pylab.colorbar() pylab.ylim(-1, 2*self.extent) pylab.xlim(-1, 2*self.extent) pylab.xlabel("Pixels") pylab.ylabel("Pixels") pylab.show()