我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用matplotlib.pyplot.clim()。
def main(): imgs = glob('images/real_ana_finger*') frames = [plt.imread(x) for x in imgs] frame_a = frames[0] frame_b = frames[1] piv = pypiv.DirectPIV(frame_a, frame_b, window_size=32, search_size=32, distance=16) u, v = piv.correlate_frames() adapt_piv = pypiv.AdaptivePIV(piv, window_size=32, search_size=32, distance=16, ipmethod='cubic') u, v = adapt_piv.correlate_frames() adapt_piv = pypiv.AdaptivePIV(piv, window_size=32, search_size=32, distance=8, ipmethod='cubic') u, v = adapt_piv.correlate_frames() plt.imshow(u) plt.clim(-5, 5) plt.show()
def savefigs(self, sess, optimizer=False): """""" import gc import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt matdir = os.path.join(self.save_dir, 'matrices') if not os.path.isdir(matdir): os.mkdir(matdir) for var in self.save_vars: if optimizer or ('Optimizer' not in var.name): print(var.name) mat = sess.run(var) if len(mat.shape) == 1: mat = mat[None,:] plt.figure() try: plt.pcolor(mat, cmap='RdBu') plt.gca().invert_yaxis() plt.colorbar() plt.clim(vmin=-1, vmax=1) plt.title(var.name) plt.savefig(os.path.join(matdir, var.name.replace('/', '-'))) except ValueError: pass plt.close() del mat gc.collect() #=============================================================
def save_image_samples(samples, save_path, exp_info, mode, arguments): N = len(samples) sqrtN = int(np.sqrt(N)) for n, sample in enumerate(samples): plt.subplot(sqrtN, sqrtN, n+1) sample = sample.contiguous().view(arguments.nfts, arguments.T) plt.imshow(sample.cpu().numpy(), cmap='binary') plt.clim(0,1) plt.savefig(os.path.join(save_path, exp_info + '_' + mode +'.png'))
def updateColorBar(self, val): """Update slider for scaling log colorbar in 2D hist.""" histVMax = np.power(10, self.sHistC.val) plt.clim(vmax=histVMax)