def plot_single_circle_grid(centroids, radiuses, ax, intensities, grid=True, alpha=0.75): # intensities = np.ma.masked_equal(abs(np.array(intensities)), .0) patches = [] count = 0 if grid: for n, x in enumerate(centroids): for y, r in zip(centroids, radiuses): # ax.text(x, y, count) count += 1 circle = Circle((x, y), r) patches.append(circle) else: for xy, r in zip(centroids, radiuses): count += 1 circle = Circle(xy, r) patches.append(circle) sorted_index = [idx for (intensity, idx) in sorted(zip(intensities, range(len(intensities))))] patches = [patches[idx] for idx in sorted_index] intensities = [intensities[idx] for idx in sorted_index] norm = mpl.colors.Normalize(vmin=0.0, vmax=max(intensities)) cm.jet.set_bad(color='white', alpha=0.0) colors = [('white')] + [(cm.jet(i)) for i in xrange(1, 256)] new_map = mpl.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256) p = PatchCollection(patches, cmap=new_map, alpha=alpha, norm=norm, linewidth=0) p.set_array(np.array(intensities)) ax.add_collection(p) ax.annotate(int(np.sqrt(count)), xy=(2, 90), fontsize=30, path_effects=[PathEffects.withStroke(linewidth=3, foreground="w")])
def __init__(self,vidfile,labelfile,modelFile,labelListFile,exportPath, perClassFrames=40,frameRate=20,context_size=5, banerWidth = 80,scale = 1): # input properties self.vidreader = VideoReader(vidfile); self.labelreader = open(labelfile,'r'); self.N = self.vidreader.frames; self.width,self.height = self.vidreader.width,self.vidreader.height; self.context_size=context_size; self.perClassFrames = perClassFrames; self.labels = load_labels(labelListFile); self.n_outs = len(self.labels); self.flag_colors = []; for index in range(self.n_outs): self.flag_colors.extend([tuple(np.array(cm.jet(index/float(self.n_outs))[:3][::-1])*255)]) self.predictors,self.predictorStartIdx = load_predictors(modelFile); self.input_shape = [self.height,self.width,3] self.batch_size = self.predictors[0].batch_size #write properites self.banerWidth = banerWidth self.vidWriter = VideoWriter(exportPath,self.banerWidth+self.width,self.height,fps=frameRate); self.colors = np.random.randint(256, size=(len(self.labels), 3)) self.scale = scale; #status self.frameIdx = 0; self.tasks = deque(); self.isFinished = False; self.vidWriter.build();
def load_unbalancing(self,ax,dict,hosts): """Extract the data for plotting the hostname balancings between different categories in bar chart""" import numpy as np from pylab import cm width=0.50 plts=[] key_legend=[] values_legend=[] icol=1.0 show_initially=[] for cat in self.classes: if cat=='Unknown': continue try: unb=np.array(dict[cat][2:]) #print 'unbalancing',unb #unb2=self.find_unbalanced(unb) #print 'unbalanced objects',cat #if hosts is not None and (cat=='Convolutions' or cat =='Communications'): #print 'unb2',unb2,len(unb),len(hosts) #print 'vals',[ [i,unb[i],hosts[i]] for i in unb2] ind=np.arange(len(unb)) pltmp=ax.bar(ind,unb,width,color=cm.jet(icol/len(self.classes))) plts.append(pltmp) key_legend.append(pltmp[0]) values_legend.append(cat) show_initially.append(dict[cat][0] > 5.0) icol+=1.0 if (width > 0.05): width -= 0.05 except Exception,e: print 'EXCEPTION FOUND',e print "cat",cat,"not found in workload data" return None
def _draw_barplot(self,axbars,data,vals,title='Time bar chart',static=False,nokey=False): import numpy as np from pylab import cm as cm ndata=len(data[0][1]) ind=np.arange(ndata) bot=np.array(ndata*[0.0]) width=self.barwidth icol=1.0 for cat,dat in data: #print 'cat',cat,dat #for i in range(len(self.ids)): # print self.ids[i],dat[i] plt=axbars.bar(ind,dat,width,bottom=bot,color=cm.jet(icol/len(data)),picker=True,label=cat) #self.plts.append(plt) bot+=dat icol+=1.0 #drawn_classes=np.array(self.values_legend) axbars.set_title(title,fontsize=self.fontsize) axbars.set_ylabel(vals,fontsize=self.fontsize) axbars.set_xticks(ind+width/2.) axbars.set_xticklabels(np.array(self.ids),size=self.fontsize) if not nokey: #self.leg = axbars.legend(loc='upper right',fontsize=self.fontsize) self.leg = axbars.legend(loc='best',fontsize=self.fontsize) self.leg.get_frame().set_alpha(0.4) #treat the totals differently return bot
def barcode_radii(ph, new_fig=True, subplot=False, linewidth=1.2, diam_max=2.0, **kwargs): """ Generates a 2d figure (barcode) of the persistent homology """ from pylab import cm # Initialization of matplotlib figure and axes. fig, ax = _view.common.get_figure(new_fig=new_fig, subplot=subplot) # Hach for colorbar creation Z = [[0, 0], [0, 0]] levels = _np.linspace(0.0, diam_max, 200) CS3 = _view.common.plt.contourf(Z, levels, cmap=cm.jet) ph_sort = sort_ph_radii(ph) for ip, p in enumerate(ph_sort): ax.plot(p[:2], [ip, ip], c=cm.jet(p[2] / diam_max), linewidth=linewidth) kwargs['title'] = kwargs.get('title', 'Barcode of p.h.') kwargs['xlabel'] = kwargs.get('xlabel', 'Lifetime') _view.common.plt.ylim([-1, len(ph_sort)]) _view.common.plt.colorbar(CS3) return _view.common.plot_style(fig=fig, ax=ax, **kwargs)
def __init__(self,parent=None,aspectratio=-1, *args): QtGui.QWidget.__init__(self, parent, *args) self._i=numpy.zeros((1,1,4),dtype=numpy.uint8) self.aspectratio=aspectratio self.setMinimumHeight(48) self.setMinimumWidth(64) self.i=QtGui.QImage(self._i.data,self._i.shape[1],self._i.shape[0],self._i.shape[1]*self._i.shape[2],self.imgconvarray[self._i.shape[2]]) self.colortable=[ (numpy.array(cm.jet(x)[0:3])*256.).astype(numpy.uint8) for x in range(0,256) ]
def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self._i=numpy.zeros((1,1,4),dtype=numpy.uint8) self.i=QtGui.QImage(self._i.data,self._i.shape[1],self._i.shape[0],self.imgconvarray[self._i.shape[2]]) self.colortable=[ (numpy.array(cm.jet(x)[0:3])*256.).astype(numpy.uint8) for x in range(0,256) ] if (FULLSCREEN): self.set_fullscreen() self.show() self.setFocus()
def plot_dsd(dsd, range=None, log_scale=True, tighten=True): '''Plotting function for drop size distribution Nd plot_dsd creates a pcolormesh based plot for a drop size distribution object's `Nd` field. Parameters ---------- dsd: DropSizeDistribution Drop Size Distribution instance containing a `Nd`. range: tuple A tuple containing the range to be plotted in form (x_begin,x_end,y_begin,y_end) log_scale: boolean Whether to plot on a log scale, or a linear scale. tighten: True Whether to restrict plot to areas with data. Returns ------- fig_handle: Figure Handle ''' fig_handle = plt.figure() colors = [('white')] + [(cm.jet(i)) for i in xrange(1, 256)] new_map = matplotlib.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256) plt.pcolor(dsd.time, dsd.diameter, np.log10(dsd.Nd.T), vmin=0.0, figure=fig_handle, cmap=new_map) plt.axis('tight') if range: plt.axis(range) else: plt.axis((0, dsd.time[-1], 0, dsd.diameter[-1])) if tighten: max_diameter = dsd.diameter[len(dsd.diameter) - np.argmax( np.nansum(dsd.Nd, axis=0)[::-1] > 0)] plt.ylim(0, max_diameter) plt.colorbar() plt.xlabel('Time(m)') plt.ylabel('Diameter(mm)') return fig_handle
def draw_boxes_2d(obbs, level, color=None, **args): from pylab import plot, cm for i, obb in enumerate(obbs): if obb.level != level: continue box = vstack([obb.box, obb.box[0]]) if color is None: plot(box.T[0], box.T[1], lw=5, hold=True, **args) else: plot(box.T[0], box.T[ 1], lw=5, hold=True, c=cm.jet(color[i]), **args)
def plot_single_circle_grid(centroids, radiuses, ax, intensities, grid=True, alpha=0.75): # intensities = np.ma.masked_equal(abs(np.array(intensities)), .0) patches = [] count = 0 if grid: for n, x in enumerate(centroids): for y, r in zip(centroids, radiuses): # ax.text(x, y, count) count += 1 circle = Circle((x, y), r) patches.append(circle) else: for xy, r in zip(centroids, radiuses): count += 1 circle = Circle(xy, r) patches.append(circle) sorted_index = [ idx for (intensity, idx) in sorted(zip(intensities, range(len(intensities)))) ] patches = [patches[idx] for idx in sorted_index] intensities = [intensities[idx] for idx in sorted_index] norm = mpl.colors.Normalize(vmin=0.0, vmax=max(intensities)) cm.jet.set_bad(color='white', alpha=0.0) colors = [('white')] + [(cm.jet(i)) for i in xrange(1, 256)] new_map = mpl.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256) p = PatchCollection(patches, cmap=new_map, alpha=alpha, norm=norm, linewidth=0) p.set_array(np.array(intensities)) ax.add_collection(p) ax.annotate( int(np.sqrt(count)), xy=(2, 90), fontsize=30, path_effects=[PathEffects.withStroke(linewidth=3, foreground="w")])
def load_unbalancing(self,ax,dict,hosts): """Extract the data for plotting the hostname balancings between different categories in bar chart""" import numpy as np from pylab import cm width=0.50 plts=[] key_legend=[] values_legend=[] icol=1.0 show_initially=[] for cat in self.classes: if cat=='Unknown': continue try: unb=np.array(dict[cat][2:]) #print 'unbalancing',unb #unb2=self.find_unbalanced(unb) #print 'unbalanced objects',cat #if hosts is not None and (cat=='Convolutions' or cat =='Communications'): #print 'unb2',unb2,len(unb),len(hosts) #print 'vals',[ [i,unb[i],hosts[i]] for i in unb2] ind=np.arange(len(unb)) pltmp=ax.bar(ind,unb,width,color=cm.jet(icol/len(self.classes))) plts.append(pltmp) key_legend.append(pltmp[0]) values_legend.append(cat) show_initially.append(dict[cat][0] > 5.0) icol+=1.0 if (width > 0.05): width -= 0.05 except Exception as e: print('EXCEPTION FOUND',e) print("cat",cat,"not found in workload data") return None if len(ind) > 2: tmp=np.array(hosts) if hosts is not None else None else: tmp=np.array(["max","min"]) ax.set_ylabel('Load Unbalancing wrt average') ax.set_title('Work Load of different classes') if tmp is not None: ax.set_xticks(ind+width/2.) ax.set_xticklabels(tmp,rotation=90,verticalalignment='bottom') ax.set_yticks(np.arange(0,2,0.25)) ax.axhline(1.0,color='k',linestyle='--') leg=ax.legend(np.array(key_legend),np.array(values_legend))#,fancybox=True, shadow=True) #leg.get_frame().set_alpha(0.4) #show only the most relevant categories return leg,plts,show_initially
def plot_dsd(dsd, range=None, log_scale=True, tighten=True): '''Plotting function for drop size distribution Nd plot_dsd creates a pcolor based plot for a drop size distribution object's `Nd` field. Parameters ---------- dsd: DropSizeDistribution Drop Size Distribution instance containing a `Nd`. range: tuple A tuple containing the range to be plotted in form (x_begin,x_end,y_begin,y_end) log_scale: boolean Whether to plot on a log scale, or a linear scale. tighten: True Whether to restrict plot to areas with data. Returns ------- fig_handle: Figure Handle ''' fig_handle = plt.figure() colors = [('white')] + [(cm.jet(i)) for i in xrange(1, 256)] new_map = matplotlib.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256) plt.pcolor(dsd.time, dsd.diameter, np.log10(dsd.Nd.T), vmin=0.0, figure=fig_handle, cmap=new_map) plt.axis('tight') if range: plt.axis(range) else: plt.axis((0, dsd.time[-1], 0, dsd.diameter[-1])) if tighten: max_diameter = dsd.diameter[len(dsd.diameter) - np.argmax(np.nansum(dsd.Nd, axis=0)[::-1] > 0)] plt.ylim(0, max_diameter) plt.colorbar() plt.xlabel('Time(m)') plt.ylabel('Diameter(mm)') return fig_handle
def draw_boxes_2d(obbs, level, color=None, **args): from pylab import plot, cm for i, obb in enumerate(obbs): if obb.level != level: continue box = vstack([obb.box, obb.box[0]]) if color is None: plot(box.T[0], box.T[1], lw=5, hold=True, **args) else: plot(box.T[0], box.T[1], lw=5, hold=True, c=cm.jet(color[i]), **args)
def scatter_classic(x, y, s=None, c='b'): """ SCATTER_CLASSIC(x, y, s=None, c='b') Make a scatter plot of x versus y. s is a size (in data coords) and can be either a scalar or an array of the same length as x or y. c is a color and can be a single color format string or an length(x) array of intensities which will be mapped by the colormap jet. If size is None a default size will be used Copied from older version of matplotlib -- removed in version 0.9.1 for whatever reason. """ self = gca() if not self._hold: self.cla() if is_string_like(c): c = [c] * len(x) elif not iterable(c): c = [c] * len(x) else: norm = normalize() norm(c) c = cm.jet(c) if s is None: s = [abs(0.015 * (amax(y) - amin(y)))] * len(x) elif not iterable(s): s = [s] * len(x) if len(c) != len(x): raise ValueError, 'c and x are not equal lengths' if len(s) != len(x): raise ValueError, 's and x are not equal lengths' patches = [] for thisX, thisY, thisS, thisC in zip(x, y, s, c): circ = Circle( (thisX, thisY), radius=thisS, ) circ.set_facecolor(thisC) self.add_patch(circ) patches.append(circ) self.autoscale_view() return patches
def scatter_classic(x, y, s=None, c='b'): """ SCATTER_CLASSIC(x, y, s=None, c='b') Make a scatter plot of x versus y. s is a size (in data coords) and can be either a scalar or an array of the same length as x or y. c is a color and can be a single color format string or an length(x) array of intensities which will be mapped by the colormap jet. If size is None a default size will be used Copied from older version of matplotlib -- removed in version 0.9.1 for whatever reason. """ self = gca() if not self._hold: self.cla() if is_string_like(c): c = [c]*len(x) elif not iterable(c): c = [c]*len(x) else: norm = normalize() norm(c) c = cm.jet(c) if s is None: s = [abs(0.015*(amax(y)-amin(y)))]*len(x) elif not iterable(s): s = [s]*len(x) if len(c)!=len(x): raise ValueError, 'c and x are not equal lengths' if len(s)!=len(x): raise ValueError, 's and x are not equal lengths' patches = [] for thisX, thisY, thisS, thisC in zip(x,y,s,c): circ = Circle( (thisX, thisY), radius=thisS, ) circ.set_facecolor(thisC) self.add_patch(circ) patches.append(circ) self.autoscale_view() return patches
def __init__(self,parent,subimages=5, aspectratio=-1, *args): QtGui.QWidget.__init__(self,parent, *args) self.subimages=subimages self._i=numpy.zeros((90,120,4),dtype=numpy.uint8) self.t=None if (self._i.ndim==2): self._i=self._i.reshape(self._i.shape+(1,)).repeat(3,axis=2) self.i=QtGui.QImage(self._i.data,self._i.shape[1],self._i.shape[0],self.imgconvarray[self._i.shape[2]]) if (self.subimages): self._si=[None]* self.subimages self.si=[None]* self.subimages for sii in range(self.subimages): self._si[sii]=numpy.zeros((90,120,4),dtype=numpy.uint8) self.si[sii]=QtGui.QImage(self._si[sii].data,self._si[sii].shape[1],self._si[sii].shape[0],self.imgconvarray[self._si[sii].shape[2]]) self.colortable=[ (numpy.array(cm.jet(x)[0:3])*256.).astype(numpy.uint8) for x in range(0,256) ] self.setMinimumHeight(self._i.shape[0]) self.setMinimumWidth(self._i.shape[1]) self.aspectratio=aspectratio
def compute_scenario(hunting_rate_x, hunting_rate_y, duration): ''' Compute multiple simulations with parameters taken from the arguments. Create graph that shows the simulation results one after the other. ARGUMENTS --------- hunting_rate_x: list of hunting rates for species 1 (small fish) hunting_rate_y: list of hunting rates for species 2 (predatory fish) duration: list of duration for each simulation ''' model = EnhancedModel() #create a simulation object instance figure() #create new figure window max_i = len(duration)-1 x, y = 1, 0.1 cum_duration = 0 #do simulations with the different parameter values, plot results for i in range(len(duration)): model.init_hunting(hunting_rate_x[i], hunting_rate_y[i], x, y, duration[i]) model.simulateDynamic() #solve ODE res = model.getResults() #get results as a storage.DictStore object color_tuple = cm.jet(i/max_i) #label_str = 'r1=%g' % r1 #create descriptive string label_str = 'hx: %g, hy: %g' % (hunting_rate_x[i], hunting_rate_y[i]) plot(res['time'] + cum_duration, res['x'], label='x: '+label_str, color=color_tuple, linestyle=':') plot(res['time'] + cum_duration, res['y'], label='y: ', color=color_tuple, linestyle='--') plot(res['time'] + cum_duration, res['hunting_yield'], label='yield: ', color=color_tuple, linestyle='-') #start next simulation with state values from previous simulation x = res['x'][-1] y = res['y'][-1] #cumulative duration to put the simulation's plots after each other cum_duration += duration[i] #finishing touches on plot xlabel('time') ylabel('x: prey, y: predators') legend() title('Predator prey with hunting')
def visualize_save_v2(vis_data, threshold, title, im_format, gt_im_files, vis_folder=None, bshow=True, frame_step=5, pause_time=1.0): F0_diff = vis_data.F0_diff F0_diff_min = F0_diff.min() F0_diff_max = F0_diff.max() if len(vis_data.M0_diff.shape) == 4: M0_diff_OF = vis_data.M0_diff[:, :, :, 1] else: M0_diff_OF = vis_data.M0_diff M0_diff_OF_min = M0_diff_OF.min() M0_diff_OF_max = M0_diff_OF.max() F4_diff = vis_data.F4_diff F4_diff_min = F4_diff.min() F4_diff_max = F4_diff.max() M4_diff = vis_data.M4_diff M4_diff_min = M4_diff.min() M4_diff_max = M4_diff.max() E_map = vis_data.E_map E_map_min = E_map.min() E_map_max = E_map.max() # D_map = vis_data.D_map D_map_2 = vis_data.D_map_2 fontsz = 7 titlefontsz = fontsz matplotlib.rcParams.update({'font.size': fontsz}) # resz = grid['imsz'] num_data, height, width, n_channels = vis_data.F0.shape nr = 6 nc = 4 if bshow == True: figsize = matplotlib.rcParams['figure.figsize'] figsize = [figsize[0], figsize[1] * 2.0] fig, axes = plt.subplots(nr, nc, figsize=figsize) plt.show(block=False) for i in range(0, num_data, frame_step): if bshow == True: c = 1 plt.clf() ax = plt.subplot(nr, nc, c) plt.cla() # plt.imshow(im_resz, cmap='Greys_r', vmin=0, vmax=255) if vis_data.layer_ids[0] == 0: plt.imshow(convertm1p1to01(vis_data.F0[i, :, :, :]), cmap='Greys_r', vmin=0, vmax=1.0) else: plt.imshow(convertm1p1to01( vis_data.F0[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0, vmax=1.0) ax.set_title('F0', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() if vis_data.layer_ids[0] == 0: plt.imshow(convertm1p1to01(vis_data.M0[i, :, :, :]), cmap='jet', vmin=0.0, vmax=1.0) else: plt.imshow(convertm1p1to01( vis_data.M0[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('M0-OF', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(convertm1p1to01(vis_data.F4[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('F4-mean', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(convertm1p1to01(vis_data.M4[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('M4-mean', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() # reconstruction maps c += 1 ax = plt.subplot(nr, nc, c) plt.cla() # plt.imshow(im_resz, cmap='Greys_r', vmin=0, vmax=255) if vis_data.layer_ids[0] == 0: plt.imshow(convertm1p1to01(vis_data.F0_recon[i, :, :, :]), cmap='Greys_r', vmin=0, vmax=1.0) else: plt.imshow(convertm1p1to01( vis_data.F0_recon[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0, vmax=1.0) ax.set_title('F0_recon', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() if vis_data.layer_ids[0] == 0: plt.imshow(convertm1p1to01(vis_data.M0_recon[i, :, :, :]), cmap='jet', vmin=0.0, vmax=1.0) else: plt.imshow(convertm1p1to01( vis_data.M0_recon[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('M0_recon', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(convertm1p1to01( vis_data.Fl_recon[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('Fl_recon-mean', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(convertm1p1to01( vis_data.Ml_recon[i, :, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('Ml_recon-mean', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() # difference map c += 1 ax = plt.subplot(nr, nc, c) plt.cla() if len(F0_diff.shape) == 4: plt.imshow(F0_diff[i, :, :, :], cmap='jet', vmin=F0_diff_min, vmax=F0_diff_max) else: plt.imshow(F0_diff[i, :, :], cmap='jet', vmin=F0_diff_min, vmax=F0_diff_max) # if pause_time < 0: # plt.colorbar() # elif i == 0: # plt.colorbar() plt.colorbar() ax.set_title('F0_diff', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() if len(M0_diff_OF.shape) == 4: pass else: plt.imshow(M0_diff_OF[i, :, :], cmap='jet', vmin=M0_diff_OF_min, vmax=M0_diff_OF_max) # if pause_time < 0: # plt.colorbar() # elif i == 0: # plt.colorbar() plt.colorbar() ax.set_title('M0_diff_OF', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() if len(F4_diff.shape) == 4: plt.imshow(F4_diff[i, :, :, :].mean(axis=2), cmap='jet', vmin=F4_diff_min, vmax=F4_diff_max) else: plt.imshow(F4_diff[i, :, :], cmap='jet', vmin=F4_diff_min, vmax=F4_diff_max) ax.set_title('F4_diff-mean', fontsize=titlefontsz) # if pause_time < 0: # plt.colorbar() # elif i == 0: # plt.colorbar() plt.colorbar() ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() if len(M4_diff.shape) == 4: plt.imshow(M4_diff[i, :, :, :].mean(axis=2), cmap='jet', vmin=M4_diff_min, vmax=M4_diff_max) else: plt.imshow(M4_diff[i, :, :], cmap='jet', vmin=M4_diff_min, vmax=M4_diff_max) ax.set_title('M4_diff-mean', fontsize=titlefontsz) # if pause_time < 0: # plt.colorbar() # elif i == 0: # plt.colorbar() plt.colorbar() ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) # detection maps c += 1 ax = plt.subplot(nr, nc, c) plt.cla() # plt.imshow(vis_data.F0_recon[i, :, :], cmap='jet', # vmin=vis_data.F0_recon.min(), vmax=vis_data.F0_recon.max()) plt.imshow(vis_data.D_map0[i, :, :], cmap='Greys_r') if pause_time < 0: plt.colorbar() elif i == 0: plt.colorbar() # plt.imshow(convertm1p1to01(vis_data.F0_recon[i, :, :, :]), cmap='Greys_r', vmin=0.0, # vmax=1.0) # ax.set_title('E_map0', fontsize=titlefontsz) ax.set_title('D_map0', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(vis_data.D_map2[i, :, :], cmap='Greys_r', vmin=0.0, vmax=1.0) # plt.imshow(convertm1p1to01(vis_data.M0_recon[i, :, :, 1]), cmap='jet', vmin=0.0, # vmax=1.0) # ax.set_title('D_map0', fontsize=titlefontsz) ax.set_title('D_map2', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(vis_data.D_map_abs0[i, :, :], cmap='Greys_r') ax.set_title('D_map_abs0', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(vis_data.D_map_abs2[i, :, :], cmap='Greys_r', vmin=0.0, vmax=1.0) ax.set_title('D_map_abs2', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) # final decision c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(E_map[i, :, :], cmap='jet', vmin=E_map_min, vmax=E_map_max) ax.set_title('E_map_final', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(convertm1p1to01(vis_data.D_map[i, :, :]).mean(axis=2), cmap='jet', vmin=0.0, vmax=1.0) ax.set_title('M4_recon-mean', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.colorbar() c += 1 ax = plt.subplot(nr, nc, c) plt.cla() a_i = vis_data.D_map_2[i, :, :] a_i = (a_i - a_i.min()) / (a_i.max() - a_i.min()) plt.imshow(a_i, cmap='Greys_r', vmin=0.0, vmax=1.0) ax.set_title('D_map_final', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(vis_data.normal_mask[i, :, :], cmap='Greys_r', vmin=0.0, vmax=1.0) ax.set_title('normal_mask', fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) if len(gt_im_files) > 0: gt = cv2.imread(gt_im_files[i], 0) c += 1 ax = plt.subplot(nr, nc, c) plt.cla() plt.imshow(gt, cmap='Greys_r', vmin=0, vmax=255) ax.set_title('[%d] Groundtruth' % i, fontsize=titlefontsz) ax.xaxis.grid(False) ax.yaxis.grid(False) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.suptitle('%s-frame %d' % (title, i)) # plt.show(block=False) if pause_time > 0: plt.pause(pause_time) else: pass # we should save the figure when pause_time > 0 because it makes the # figure be resized and not good for visualizaition if vis_folder is not None: fig_file = '%s/%08d.jpg' % (vis_folder, i) plt.savefig(fig_file, dpi=1200) if vis_folder is not None: score_max = E_map.max() heat_score = cm.jet(E_map[i, :, :] / score_max) cv2.imwrite('%s/%08d_score.jpg' % (vis_folder, i), reverse_channel(heat_score * 255.0)) # cv2.imwrite('%s/%08d_det.jpg' % (vis_folder, i), D_map[i, :, :]*255.0) cv2.imwrite('%s/%08d_det_2.jpg' % (vis_folder, i), D_map_2[i, :, :] * 255.0)
tag = path.split('/')[-1][-7:] os.chdir(path) if filter2 == None: structs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and filter in d]) else: structs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and d==filter2]) nStructs = len(structs) print structs,path for istruct,struct in enumerate(structs): # print 'test', istruct, struct # print 'struct',struct os.chdir(struct) calcs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and os.path.exists('{}/OUTCAR'.format(d))]) if coloring == 'indiv': # if iplot < nplots -1: color = rgb2hex(cm.jet(1.*(iplot+1)/float(nplots))) # else: # color = 'k' elif coloring == 'method': # color = colorsList[ipath] color = None energies = [] nKs = [] ns = [] #the base n of the run run nDone = 0 if useSym: try: nops,IBZvolcut,IBZvol = readSym(calcs[0]) except: sys.exit('Stopping. readSym failed. Set useSym to False')
def plot_dsd(dsd, xlims=None, ylims=None, log_scale=True, tighten=True, vmin=None, vmax=None, cmap=None, ax=None, fig=None): '''Plotting function for drop size distribution Nd plot_dsd creates a pcolormesh based plot for a drop size distribution object's `Nd` field. Parameters ---------- dsd: DropSizeDistribution Drop Size Distribution instance containing a `Nd`. xlims: 2-tuple Range of x axis (x_begin, x_end). ylims: 2-tuple Range of y axis (y_begin, y_end). log_scale: boolean Whether to plot on a log scale, or a linear scale. tighten: True Whether to restrict plot to areas with data. Returns ------- fig: Figure instance ''' ax = parse_ax(ax) fig = parse_fig(fig) if cmap is None: colors = [('white')] + [(cm.jet(i)) for i in range(1, 256)] cmap = mpl.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256) if vmin is None: vmin = np.nanmin(dsd.fields['Nd']['data']) if vmax is None: vmax = np.nanmax(dsd.fields['Nd']['data']) if log_scale: if vmin == 0.: vmin = 0.1 norm = mpl.colors.LogNorm(vmin=vmin, vmax=vmax) else: norm = None plt.pcolormesh(dsd.time['data'], dsd.diameter['data'], dsd.fields['Nd']['data'].T, vmin=vmin, vmax=vmax, figure=fig, norm=norm, cmap=cmap) plt.axis('tight') if xlims is not None: ax.set_xlim(xlims) else: ax.set_xlim(dsd.time['data'][0], dsd.time['data'][-1]) if ylims is not None: ax.set_ylim(ylims) else: ax.set_ylim(0., dsd.diameter['data'][-1]) if tighten: max_diameter = dsd.diameter['data'][ len(dsd.diameter['data']) - np.argmax(np.nansum(dsd.fields['Nd']['data'], axis=0)[::-1] > 0)] plt.ylim(0, max_diameter) plt.colorbar() plt.xlabel('Time(m)') plt.ylabel('Diameter(mm)') return fig, ax
def savejet(img, name): img = (img - img.min())/float(img.ptp())*255 img = img.astype(np.uint8) readmagick.writeimg((cm.jet(img)[:,:,:3]*255).astype(np.uint8), name)
axis('scaled') xticks([]) yticks([]) i = 0 for y in linspace(0, 1, Nx): for x in linspace(0, 1, Nx): if color[i] != Inf: if group_number[i] == selected_group: w = 4 ec = "k" # edge color else: w = 1 ec = 'k' cir = Circle((x, y), radius, fc=cm.jet(color[i]), linewidth=w, ec=ec) else: cir = Circle((x, y), radius, fc='w') i += 1 gca().add_patch(cir) xlim(0 - 2 * radius, 1 + 2 * radius) ylim(0 - 2 * radius, 1 + 2 * radius) # Remove groups with fewer than two neurons and recalculate group numbers for i in range(len(group_number)): if group_number[i] >= 0: if count[group_number[i]] >= 2: group_number[i] = sum(count[:group_number[i]] >= 2) else:
def savejet(img, name): img = (img - img.min()) / float(img.ptp()) * 255 img = img.astype(np.uint8) readmagick.writeimg((cm.jet(img)[:, :, :3] * 255).astype(np.uint8), name)
#create a couple of initial values for x and y r1Vals = linspace(0.5, 3, 10) col = linspace(0, 1, 10) #do simulations with the different parameter values, and put the results into a #phase-plane plot for i in range(len(r1Vals)): #initialize the simulation object, override some of the parameter values mo.initialize('m.r1', r1Vals[i], 'N1_init', 1, 'N2_init', 2, 'solutionParameters.simulationTime', 20, 'showGraph', 0) mo.simulateDynamic() #solve ODE res = mo.getResults() #get results as a storage.DictStore object colorStr = cm.jet(col[i]) labelStr = 'r1=%g' % (r1Vals[i]) #create descriptive string plot(res['time'], res['m.N1'], label='N1: '+labelStr, color=colorStr, linestyle='-') plot(res['time'], res['m.N2'], label='N2: '+labelStr, color=colorStr, linestyle='--') #finishing touches on plot xlabel('time') ylabel('N1, N2') legend() title('Competition of two species; case 3.') #Case 4 ---------------------------------------------- #vary the growt rate of organism 1 mo = Case4() #create a simulaton object instance
def analyze( paths ): #as used with the parameter search, paths will have only one entry. But keep consistent with interactive vaspoutCombineRunsExtData extpath = None useSym = False coloring = 'method' # coloring = 'indiv' doLegend = True doLabel = True smoothFactor = 2.0 filter = '_' #string must be in dir name to be included filter2 = None #'Cu_1' #for single structures. set to None if using filter1 only summaryPath = paths[0] #count the number of plots: iplot = 0 maxCalcs = 0 maxNk = 0 methods = [] for ipath, path in enumerate(paths): method = path.split('_')[-1].split('/')[0] methods.append(method) os.chdir(path) if filter2 == None: structs = sorted([ d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and filter in d ]) else: structs = sorted([ d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and d == filter2 ]) for struct in structs: os.chdir(struct) iplot += 1 calcs = sorted( [d for d in os.listdir(os.getcwd()) if os.path.isdir(d)]) if len(calcs) > maxCalcs: maxCalcs = len(calcs) os.chdir(path) #external data is of the form extpath/atom_method/struct.csv. The csv has energies vs nK if not extpath is None: os.chdir(extpath) atoms_methods = sorted([ d for d in os.listdir(extpath) if os.path.isdir(d) and filter in d ]) # os.chdir(extpath) for atom_method in atoms_methods: atom = atom_method.split('_')[0] os.chdir(atom_method) os.system('rm -r .*lock*') for structfile in os.listdir(os.getcwd()): if atom not in structfile: os.system('mv {} {}_{}'.format( structfile, atom, structfile)) #so that file has atom name at beginning if filter2 == None: structfiles = sorted([ d for d in os.listdir(os.getcwd()) if os.path.getsize(d) > 0 ]) else: structfiles = sorted([ d for d in os.listdir(os.getcwd()) if '_'.join(d.split('_')[:2]) == filter2 and os.path.getsize(d) > 0 ]) for structfile in structfiles: iplot += 1 #count number of points in this structfile lines = readfile(structfile) if len(lines) > maxCalcs: maxCalcs = len(lines) os.chdir(extpath) nplots = iplot if nplots < len(paths): sys.exit('Stop. Structures do not match filter') data = zeros(nplots,dtype = [('ID', 'S25'),('color', 'S15'),('method', 'S15'),\ ('nDone','int32'),('nAtoms','int32'),('nops','int8'),\ ('IBZvolcut','float'),('IBZvol','float'),\ ('eners', '{}float'.format(maxCalcs)), ('errs', '{}float'.format(maxCalcs)),\ ('nKs', '{}int16'.format(maxCalcs)),('ns', '{}int8'.format(maxCalcs))]) # style.use('bmh') # for i, item in enumerate(rcParams['axes.prop_cycle']): # colorsList.append(item['color']) style.use('fivethirtyeight') # for i, item in enumerate(rcParams['axes.prop_cycle'][:-2]): # colorsList.append(item['color']) colorsList = [ u'#30a2da', u'#fc4f30', u'#e5ae38', u'#6d904f', u'#8b8b8b', u'#348ABD', u'#A60628', u'#7A68A6', u'#467821', u'#D55E00', u'#CC79A7', u'#56B4E9', u'#009E73', u'#F0E442', u'#0072B2' ] colorsList = colorsList + ['b', 'm', 'y', 'c', 'k'] rcParams.update({'figure.autolayout': True}) rcParams['axes.facecolor'] = 'white' rcParams['axes.linewidth'] = 1.0 rcParams['axes.edgecolor'] = 'black' # axisbg=axescolor rcParams['savefig.facecolor'] = 'white' # axisbg=axescolor rcParams['lines.markersize'] = 4.5 #read all the data iplot = -1 for ipath, path in enumerate(paths): #my data tag = path.split('/')[-1][-7:] os.chdir(path) if filter2 == None: structs = sorted([ d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and filter in d ]) else: structs = sorted([ d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and d == filter2 ]) nStructs = len(structs) # print structs,path for istruct, struct in enumerate(structs): # print 'test', istruct, struct # print 'struct',struct os.chdir(struct) if coloring == 'indiv': # if iplot < nplots -1: color = rgb2hex(cm.jet(1. * (iplot + 1) / float(nplots))) # else: # color = 'k' elif coloring == 'method': # color = colorsList[ipath] color = None calcs = sorted([ d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and os.path.exists('{}/OUTCAR'.format(d)) ]) energies = [] nKs = [] ns = [] #the base n of the run run nDone = 0 if useSym: try: nops, IBZvolcut, IBZvol = readSym(calcs[0]) except: sys.exit('Stopping. readSym failed. Set useSym to False') for calc in calcs: if electronicConvergeFinish(calc): ener = getEnergy(calc) #in energy/atom if not areEqual(ener, 0, 1e-5): nDone += 1 energies.append(ener) if 'vc' in path: nK = getNkIBZ(calc, 'KPOINTS') else: nK = getNkIBZ(calc, 'IBZKPT') if nK > maxNk: maxNk = nK nKs.append(nK) ns.append(int(calc.split('_')[-1])) #sort by increasing number of kpoints if len(energies) > 0: iplot += 1 nKs = array(nKs) energies = array(energies) ns = array(ns) order = argsort(nKs) # print 'struct',struct # print 'energies',energies energies = energies[order] ns = ns[order] nKs = sort(nKs) eref = energies[ -1] #the last energy of each struct is that of the most kpoints errs = abs(energies - eref) * 1000 + 1e-4 #now in meV data[iplot]['ID'] = '{} {}'.format(struct, tag) nAtoms = getNatoms('{}/POSCAR'.format(calc)) data[iplot]['nAtoms'] = nAtoms if useSym: data[iplot]['nops'] = nops data[iplot]['IBZvolcut'] = IBZvolcut data[iplot]['nDone'] = nDone data[iplot]['eners'][:nDone] = energies data[iplot]['errs'][:nDone] = errs data[iplot]['nKs'][:nDone] = nKs data[iplot]['ns'][:nDone] = ns data[iplot]['color'] = color method = path.split('_')[-1].split('/')[0] data[iplot]['method'] = method os.chdir(path) # os.chdir(extpath) if not extpath is None: os.chdir(extpath) # print; print atoms_methods for atom_method in atoms_methods: os.chdir(atom_method) if coloring == 'method': color = None if 'MP' in atom_method: # color = colorsList[len(paths)] method = 'MP' elif 'Mueller' in atom_method: # color = colorsList[len(paths)+1] method = 'Mueller' if method not in methods: methods.append(method) if filter2 == None: structfiles = sorted([ d for d in os.listdir(os.getcwd()) if os.path.getsize(d) > 0 ]) else: structfiles = sorted([ d for d in os.listdir(os.getcwd()) if '_'.join(d.split('_')[:2]) == filter2 and os.path.getsize(d) > 0 ]) for structfile in structfiles: if useSym: nops, IBZvolcut, nAtoms = copyData(structfile, data) if coloring == 'indiv': if iplot < nplots - 1: color = cm.jet(1. * (iplot + 1) / float(nplots)) else: color = 'k' iplot += 1 energies = [] nKs = [] lines = readfile(structfile) for line in lines: nK = int(line.split('\t')[0]) if nK > maxNk: maxNk = nK nKs.append(nK) energies.append(-float(line.split('\t')[1].split('\r')[0])) nKs = array(nKs) energies = array(energies) nDone = len(energies) order = argsort(nKs) energies = energies[order] eref = energies[ -1] #the last energy of each struct is that of the most kpoints nKs = sort(nKs) errs = abs(energies - eref) * 1000 + 1e-4 #now in meV struct = '_'.join(structfile.split('_')[:2]) data[iplot]['ID'] = atom_method + struct data[iplot]['nAtoms'] = nAtoms if useSym: data[iplot]['nops'] = nops data[iplot]['IBZvolcut'] = IBZvolcut data[iplot]['nDone'] = len(energies) data[iplot]['eners'][:nDone] = energies data[iplot]['errs'][:nDone] = errs data[iplot]['nKs'][:nDone] = nKs data[iplot]['color'] = color data[iplot]['method'] = method os.chdir(extpath) nplots = iplot + 1 lines = [' ID , nKIBZ , ener , err, nAtoms, nops,IBZcut\n'] for iplot in range(nplots): n = data[iplot]['nDone'] for icalc in range(n): #data[iplot]['eners'][:n].tolist() lines.append('{}_n{},{},{:15.12f},{:15.12f},{},{},{}\n'.format(data[iplot]['ID'],\ data[iplot]['ns'][icalc], data[iplot]['nKs'][icalc],\ data[iplot]['eners'][icalc],data[iplot]['errs'][icalc],\ data[iplot]['nAtoms'],data[iplot]['nops'],data[iplot]['IBZvolcut'])) writefile(lines, '{}/summary.csv'.format(summaryPath)) #plots if maxNk > 1: if filter[0] == '_': filter = '' #labels can't begin with _ # plotTypes = ['linear','loglog', 'loglinear'];ylabels = ['Vasp error energy/atom (eV)','Error (meV)','Error (meV)'] # print 'plot only loglog' plotTypes = ['loglog'] ylabels = ['Error (meV)'] # plotTypes = [] xtext = 'N k-points' for it, plotType in enumerate(plotTypes): fig = figure() ax1 = fig.add_subplot(111) xlabel(xtext) ylabel(ylabels[it]) # title('Convergence vs mesh method') #ylim((1e-12,1e0)) oldmethod = '' methods2 = [] for iplot in range(nplots): labelStr = None n = data[iplot]['nDone'] if coloring == 'method': method = data[iplot]['method'] data[iplot]['color'] = colorsList[methods.index(method)] if method != oldmethod and method not in methods2: if doLabel: labelStr = '{} {}'.format(filter, data[iplot]['method']) plotData(fig, summaryPath, data[iplot], n, plotType, filter, doLegend, labelStr) oldmethod = method labelStr = None methods2.append(method) else: plotData(fig, summaryPath, data[iplot], n, plotType, filter, doLegend, labelStr) elif coloring == 'indiv': if doLabel: labelStr = '{} {}'.format(filter, data[iplot]['ID']) plotData(data[iplot], n, plotType, filter, doLegend, labelStr) #Method averaging if coloring == 'method': # print 'Averaging, plotting method errors' nbins = int(10 * ceil(log10(maxNk))) # 10 bins per decade nKbins = array([(10.0**(1 / 10.0))**i for i in range(nbins)]) fig = figure() ax1 = fig.add_subplot(111) xlabel('N k-points (smoothed by factor {})'.format( int(smoothFactor))) ylabel('Error (meV)') methodCostsLogs = [] for im, method in enumerate(methods): methnKmax = 0 binCounts = zeros(nbins, dtype=int32) binErrs = zeros(nbins, dtype=float) costLogs = zeros( nbins, dtype=float ) # "Costs" relative to excellent Si Monkhorst Pack, which has err = 10^3/nK^3 + 10^-3 meV. for iplot in range(nplots): if data[iplot]['method'] == method: for icalc in range(data[iplot]['nDone'] - 1): nK = data[iplot]['nKs'][icalc] if nK > methnKmax: methnKmax = nK if nK > 1: for ibin in range(nbins): if abs(log10(nK/nKbins[ibin])) <= log10(smoothFactor)\ and nKbins[ibin]<= maxNk: binErrs[ibin] += data[iplot]['errs'][ icalc] costLogs[ibin] += log10( data[iplot]['errs'][icalc] / (10**3 / (nK**3.0) + 0.001)) binCounts[ibin] += 1 mask = where(binCounts > 0) binErrs2 = binErrs[mask[0]] binCounts2 = binCounts[mask[0]] nKbins2 = nKbins[mask[0]] costLogs2 = costLogs[mask[0]] nbins2 = len(nKbins2) avgErrs = [ binErrs2[ibin] / binCounts2[ibin] for ibin in range(nbins2) ] avgcostLogs = [ costLogs2[ibin] / binCounts2[ibin] for ibin in range(nbins2) ] avgcostLins = [10**avgcostLogs[ibin] for ibin in range(nbins2)] methodCostsLogs.append(mean(avgcostLogs)) loglog(nKbins2,avgErrs,label = method,\ color = colorsList[im], marker = None) loglog(nKbins2,avgcostLins,label = None,\ color = colorsList[im], marker = None,linestyle=':') # print 'Method',method, 'nKmax',methnKmax, 'avgLogCost', mean(avgcostLogs) legend(loc='lower left', prop={'size': 12}) fig.savefig('{}/methodErrs'.format(summaryPath)) close('all') if maxNk > 1: return [methodCostsLogs[0], mean(data['nDone']) ] #there is only one method when running this routine else: return [100, 0]
def plot_dsd(dsd, xlims=None, ylims=None, date_format='%H:%M', tz=None, x_min_tick_format='minute', log_scale=True, tighten=True, vmin=None, vmax=None, cmap=None, ax=None, fig=None): '''Plotting function for drop size distribution Nd plot_dsd creates a pcolormesh based plot for a drop size distribution object's `Nd` field. Parameters ---------- dsd: DropSizeDistribution Drop Size Distribution instance containing a `Nd`. xlims: 2-tuple Range of x axis (x_begin, x_end). ylims: 2-tuple Range of y axis (y_begin, y_end). log_scale: boolean Whether to plot on a log scale, or a linear scale. tighten: True Whether to restrict plot to areas with data. Returns ------- fig: Figure instance ''' ax = parse_ax(ax) fig = parse_fig(fig) x_fmt = DateFormatter(date_format) if cmap is None: colors = [('white')] + [(cm.jet(i)) for i in range(1, 256)] cmap = mpl.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256) if vmin is None: vmin = np.nanmin(dsd.fields['Nd']['data']) if vmax is None: vmax = np.nanmax(dsd.fields['Nd']['data']) if log_scale: if vmin == 0.: vmin = 0.1 norm = mpl.colors.LogNorm(vmin=vmin, vmax=vmax) else: norm = None # import pdb; pdb.set_trace() plt.pcolormesh(dsd.time['data'].filled(), dsd.bin_edges['data'].filled(), dsd.fields['Nd']['data'].T, vmin=vmin, vmax=vmax, figure=fig, norm=norm, cmap=cmap) plt.axis('tight') if xlims is not None: ax.set_xlim(xlims) else: ax.set_xlim(dsd.time['data'][0], dsd.time['data'][-1]) if ylims is not None: ax.set_ylim(ylims) else: ax.set_ylim(0., dsd.diameter['data'][-1]) ax.xaxis.set_major_formatter(x_fmt) if x_min_tick_format == 'second': ax.xaxis.set_minor_locator(SecondLocator()) elif x_min_tick_format == 'minute': ax.xaxis.set_minor_locator(MinuteLocator()) elif x_min_tick_format == 'hour': ax.xaxis.set_minor_locator(HourLocator()) elif x_min_tick_format == 'day': ax.xaxis.set_minor_locator(DayLocator()) if tighten: max_diameter = dsd.diameter['data'][ len(dsd.diameter['data']) - np.argmax(np.nansum(dsd.fields['Nd']['data'], axis=0)[::-1] > 0)] plt.ylim(0, max_diameter) clb = plt.colorbar() clb.set_label('Number of Drops', fontsize=16) plt.xlabel('Time [UTC]', fontsize=16) plt.ylabel('Diameter [mm]', fontsize=16) return fig, ax
def plot_dsd( dsd, xlims=None, ylims=None, log_scale=True, tighten=True, vmin=None, vmax=None, cmap=None, ax=None, fig=None, ): """Plotting function for drop size distribution Nd plot_dsd creates a pcolormesh based plot for a drop size distribution object's `Nd` field. Parameters ---------- dsd: DropSizeDistribution Drop Size Distribution instance containing a `Nd`. xlims: 2-tuple Range of x axis (x_begin, x_end). ylims: 2-tuple Range of y axis (y_begin, y_end). log_scale: boolean Whether to plot on a log scale, or a linear scale. tighten: True Whether to restrict plot to areas with data. Returns ------- fig: Figure instance """ ax = parse_ax(ax) fig = parse_fig(fig) if cmap is None: colors = [("white")] + [(cm.jet(i)) for i in range(1, 256)] cmap = mpl.colors.LinearSegmentedColormap.from_list("new_map", colors, N=256) if vmin is None: vmin = np.nanmin(dsd.fields["Nd"]["data"]) if vmax is None: vmax = np.nanmax(dsd.fields["Nd"]["data"]) if log_scale: if vmin == 0.: vmin = 0.1 norm = mpl.colors.LogNorm(vmin=vmin, vmax=vmax) else: norm = None import pdb pdb.set_trace() plt.pcolormesh( dsd.time["data"].filled(), dsd.diameter["data"].filled(), dsd.fields["Nd"]["data"].T, vmin=vmin, vmax=vmax, figure=fig, norm=norm, cmap=cmap, ) plt.axis("tight") if xlims is not None: ax.set_xlim(xlims) else: ax.set_xlim(dsd.time["data"][0], dsd.time["data"][-1]) if ylims is not None: ax.set_ylim(ylims) else: ax.set_ylim(0., dsd.diameter["data"][-1]) if tighten: max_diameter = dsd.diameter["data"][ len(dsd.diameter["data"]) - np.argmax(np.nansum(dsd.fields["Nd"]["data"], axis=0)[::-1] > 0) ] plt.ylim(0, max_diameter) plt.colorbar() plt.xlabel("Time(m)") plt.ylabel("Diameter(mm)") return fig, ax
global stepsToToleranceArray with open('assets1/b.pkl', 'wb') as file: pickle.dump(stepsToToleranceArray, file) # ----------------------- Main if input('1. Run calculation\n2. Import data\n') in ['1', '1.']: calculate() # comment to obly load data storeDataToFile() # comment to only load data loadDataFromFile() # ----------------------- Plot commonLinewidth = 2 blue = plcm.jet(0.1) yellow = plcm.jet(0.56) red = plcm.jet(0.9) plt.subplot(2, 1, 1) # linear plot plt.plot(nArray, stepsToToleranceArray_a, linewidth=commonLinewidth, marker='.', markersize=8, color='b') plt.plot(nArray, stepsToToleranceArray, linewidth=commonLinewidth, marker='.', markersize=8,
# Display the synchrony partition (Fig. 2A) axes(frameon=False) axis('scaled') xticks([]) yticks([]) i=0 for y in linspace(0,1,Nx): for x in linspace(0,1,Nx): if color[i]!=Inf: if group_number[i]==selected_group: w=4 ec="k" # edge color else: w=1 ec='k' cir=Circle((x,y),radius,fc=cm.jet(color[i]),linewidth=w,ec=ec) else: cir=Circle((x,y),radius,fc='w') i+=1 gca().add_patch(cir) xlim(0-2*radius,1+2*radius) ylim(0-2*radius,1+2*radius) # Remove groups with fewer than two neurons and recalculate group numbers for i in range(len(group_number)): if group_number[i]>=0: if count[group_number[i]]>=2: group_number[i]=sum(count[:group_number[i]]>=2) else: group_number[i]=-1
def analyze(paths): #as used with the parameter search, paths will have only one entry. But keep consistent with interactive vaspoutCombineRunsExtData extpath = None useSym = False coloring = 'method' # coloring = 'indiv' doLegend = True doLabel = True smoothFactor = 2.0 filter = '_' #string must be in dir name to be included filter2 = None #'Cu_1' #for single structures. set to None if using filter1 only summaryPath = paths[0] #count the number of plots: iplot = 0 maxCalcs = 0 maxNk = 0 methods = [] for ipath,path in enumerate(paths): method = path.split('_')[-1].split('/')[0] methods.append(method) os.chdir(path) if filter2 == None: structs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and filter in d]) else: structs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and d==filter2]) for struct in structs: os.chdir(struct) iplot += 1 calcs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d)]) if len(calcs)>maxCalcs: maxCalcs = len(calcs) os.chdir(path) #external data is of the form extpath/atom_method/struct.csv. The csv has energies vs nK if not extpath is None: os.chdir(extpath) atoms_methods = sorted([d for d in os.listdir(extpath) if os.path.isdir(d) and filter in d])# os.chdir(extpath) for atom_method in atoms_methods: atom = atom_method.split('_')[0] os.chdir(atom_method) os.system('rm -r .*lock*') for structfile in os.listdir(os.getcwd()): if atom not in structfile: os.system('mv {} {}_{}'.format(structfile,atom,structfile)) #so that file has atom name at beginning if filter2 == None: structfiles = sorted([d for d in os.listdir(os.getcwd()) if os.path.getsize(d)>0]) else: structfiles = sorted([d for d in os.listdir(os.getcwd()) if '_'.join(d.split('_')[:2])==filter2 and os.path.getsize(d)>0]) for structfile in structfiles: iplot += 1 #count number of points in this structfile lines = readfile(structfile) if len(lines)>maxCalcs: maxCalcs = len(lines) os.chdir(extpath) nplots = iplot if nplots < len(paths): sys.exit('Stop. Structures do not match filter') data = zeros(nplots,dtype = [('ID', 'S25'),('color', 'S15'),('method', 'S15'),\ ('nDone','int32'),('nAtoms','int32'),('nops','int8'),\ ('IBZvolcut','float'),('IBZvol','float'),\ ('eners', '{}float'.format(maxCalcs)), ('errs', '{}float'.format(maxCalcs)),\ ('nKs', '{}int16'.format(maxCalcs)),('ns', '{}int8'.format(maxCalcs))]) # style.use('bmh') # for i, item in enumerate(rcParams['axes.prop_cycle']): # colorsList.append(item['color']) style.use('fivethirtyeight') # for i, item in enumerate(rcParams['axes.prop_cycle'][:-2]): # colorsList.append(item['color']) colorsList = [u'#30a2da', u'#fc4f30', u'#e5ae38', u'#6d904f', u'#8b8b8b', u'#348ABD', u'#A60628', u'#7A68A6', u'#467821', u'#D55E00', u'#CC79A7', u'#56B4E9', u'#009E73', u'#F0E442', u'#0072B2'] colorsList = colorsList + ['b','m','y','c','k'] rcParams.update({'figure.autolayout': True}) rcParams['axes.facecolor'] = 'white' rcParams['axes.linewidth'] = 1.0 rcParams['axes.edgecolor'] = 'black' # axisbg=axescolor rcParams['savefig.facecolor'] = 'white' # axisbg=axescolor rcParams['lines.markersize'] = 4.5 #read all the data iplot = -1 for ipath, path in enumerate(paths): #my data tag = path.split('/')[-1][-7:] os.chdir(path) if filter2 == None: structs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and filter in d]) else: structs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and d==filter2]) nStructs = len(structs) # print structs,path for istruct,struct in enumerate(structs): # print 'test', istruct, struct # print 'struct',struct os.chdir(struct) if coloring == 'indiv': # if iplot < nplots -1: color = rgb2hex(cm.jet(1.*(iplot+1)/float(nplots))) # else: # color = 'k' elif coloring == 'method': # color = colorsList[ipath] color = None calcs = sorted([d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and os.path.exists('{}/OUTCAR'.format(d))]) energies = [] nKs = [] ns = [] #the base n of the run run nDone = 0 if useSym: try: nops,IBZvolcut,IBZvol = readSym(calcs[0]) except: sys.exit('Stopping. readSym failed. Set useSym to False') for calc in calcs: if electronicConvergeFinish(calc): ener = getEnergy(calc) #in energy/atom if not areEqual(ener,0,1e-5): nDone +=1 energies.append(ener) if 'vc' in path: nK = getNkIBZ(calc,'KPOINTS') else: nK = getNkIBZ(calc,'IBZKPT') if nK > maxNk: maxNk = nK nKs.append(nK) ns.append(int(calc.split('_')[-1])) #sort by increasing number of kpoints if len(energies)>0: iplot += 1 nKs = array(nKs) energies = array(energies) ns = array(ns) order = argsort(nKs) # print 'struct',struct # print 'energies',energies energies = energies[order] ns = ns[order] nKs = sort(nKs) eref = energies[-1]#the last energy of each struct is that of the most kpoints errs = abs(energies-eref)*1000 + 1e-4 #now in meV data[iplot]['ID'] = '{} {}'.format(struct,tag) nAtoms = getNatoms('{}/POSCAR'.format(calc)) data[iplot]['nAtoms'] = nAtoms if useSym: data[iplot]['nops'] = nops data[iplot]['IBZvolcut'] = IBZvolcut data[iplot]['nDone'] = nDone data[iplot]['eners'][:nDone] = energies data[iplot]['errs'][:nDone] = errs data[iplot]['nKs'][:nDone] = nKs data[iplot]['ns'][:nDone] = ns data[iplot]['color'] = color method = path.split('_')[-1].split('/')[0] data[iplot]['method'] = method os.chdir(path) # os.chdir(extpath) if not extpath is None: os.chdir(extpath) # print; print atoms_methods for atom_method in atoms_methods: os.chdir(atom_method) if coloring == 'method': color = None if 'MP' in atom_method: # color = colorsList[len(paths)] method = 'MP' elif 'Mueller' in atom_method: # color = colorsList[len(paths)+1] method = 'Mueller' if method not in methods: methods.append(method) if filter2 == None: structfiles = sorted([d for d in os.listdir(os.getcwd()) if os.path.getsize(d)>0]) else: structfiles = sorted([d for d in os.listdir(os.getcwd()) if '_'.join(d.split('_')[:2])==filter2 and os.path.getsize(d)>0]) for structfile in structfiles: if useSym: nops,IBZvolcut,nAtoms = copyData(structfile,data) if coloring == 'indiv': if iplot < nplots -1: color = cm.jet(1.*(iplot+1)/float(nplots)) else: color = 'k' iplot += 1 energies = [] nKs = [] lines = readfile(structfile) for line in lines: nK = int(line.split('\t')[0]) if nK > maxNk: maxNk = nK nKs.append(nK) energies.append(-float(line.split('\t')[1].split('\r')[0])) nKs = array(nKs) energies = array(energies) nDone = len(energies) order = argsort(nKs) energies = energies[order] eref = energies[-1]#the last energy of each struct is that of the most kpoints nKs = sort(nKs) errs = abs(energies-eref)*1000 + 1e-4 #now in meV struct = '_'.join(structfile.split('_')[:2]) data[iplot]['ID'] = atom_method + struct data[iplot]['nAtoms'] = nAtoms if useSym: data[iplot]['nops'] = nops data[iplot]['IBZvolcut'] = IBZvolcut data[iplot]['nDone'] = len(energies) data[iplot]['eners'][:nDone] = energies data[iplot]['errs'][:nDone] = errs data[iplot]['nKs'][:nDone] = nKs data[iplot]['color'] = color data[iplot]['method'] = method os.chdir(extpath) nplots = iplot+1 lines = [' ID , nKIBZ , ener , err, nAtoms, nops,IBZcut\n'] for iplot in range(nplots): n = data[iplot]['nDone'] for icalc in range(n):#data[iplot]['eners'][:n].tolist() lines.append('{}_n{},{},{:15.12f},{:15.12f},{},{},{}\n'.format(data[iplot]['ID'],\ data[iplot]['ns'][icalc], data[iplot]['nKs'][icalc],\ data[iplot]['eners'][icalc],data[iplot]['errs'][icalc],\ data[iplot]['nAtoms'],data[iplot]['nops'],data[iplot]['IBZvolcut'])) writefile(lines,'{}/summary.csv'.format(summaryPath)) #plots if maxNk > 1: if filter[0] == '_':filter = '' #labels can't begin with _ # plotTypes = ['linear','loglog', 'loglinear'];ylabels = ['Vasp error energy/atom (eV)','Error (meV)','Error (meV)'] # print 'plot only loglog' plotTypes = ['loglog']; ylabels = ['Error (meV)'] # plotTypes = [] xtext = 'N k-points' for it,plotType in enumerate(plotTypes): fig = figure() ax1 = fig.add_subplot(111) xlabel(xtext) ylabel(ylabels[it]) # title('Convergence vs mesh method') #ylim((1e-12,1e0)) oldmethod = '' methods2 = [] for iplot in range(nplots): labelStr = None n = data[iplot]['nDone'] if coloring == 'method': method = data[iplot]['method'] data[iplot]['color'] = colorsList[methods.index(method)] if method != oldmethod and method not in methods2: if doLabel: labelStr = '{} {}'.format(filter,data[iplot]['method']) plotData(fig,summaryPath,data[iplot],n,plotType,filter,doLegend,labelStr) oldmethod = method;labelStr = None methods2.append(method) else: plotData(fig,summaryPath,data[iplot],n,plotType,filter,doLegend,labelStr) elif coloring == 'indiv': if doLabel: labelStr = '{} {}'.format(filter,data[iplot]['ID']) plotData(data[iplot],n,plotType,filter,doLegend,labelStr) #Method averaging if coloring == 'method': # print 'Averaging, plotting method errors' nbins = int(10*ceil(log10(maxNk)))# 10 bins per decade nKbins = array([(10.0**(1/10.0))**i for i in range(nbins)]) fig = figure() ax1 = fig.add_subplot(111) xlabel('N k-points (smoothed by factor {})'.format(int(smoothFactor))) ylabel('Error (meV)') methodCostsLogs = [] for im,method in enumerate(methods): methnKmax = 0 binCounts = zeros(nbins,dtype = int32) binErrs = zeros(nbins,dtype = float) costLogs = zeros(nbins,dtype = float) # "Costs" relative to excellent Si Monkhorst Pack, which has err = 10^3/nK^3 + 10^-3 meV. for iplot in range(nplots): if data[iplot]['method'] == method: for icalc in range(data[iplot]['nDone']-1): nK = data[iplot]['nKs'][icalc] if nK>methnKmax: methnKmax = nK if nK>1: for ibin in range(nbins): if abs(log10(nK/nKbins[ibin])) <= log10(smoothFactor)\ and nKbins[ibin]<= maxNk: binErrs[ibin] += data[iplot]['errs'][icalc] costLogs[ibin] += log10(data[iplot]['errs'][icalc]/(10**3/(nK**3.0)+0.001)) binCounts[ibin] += 1 mask = where(binCounts>0) binErrs2 = binErrs[mask[0]] binCounts2 = binCounts[mask[0]] nKbins2 = nKbins[mask[0]] costLogs2 = costLogs[mask[0]] nbins2 = len(nKbins2) avgErrs = [binErrs2[ibin]/binCounts2[ibin] for ibin in range(nbins2)] avgcostLogs = [costLogs2[ibin]/binCounts2[ibin] for ibin in range(nbins2)] avgcostLins = [10**avgcostLogs[ibin] for ibin in range(nbins2)] methodCostsLogs.append(mean(avgcostLogs)) loglog(nKbins2,avgErrs,label = method,\ color = colorsList[im], marker = None) loglog(nKbins2,avgcostLins,label = None,\ color = colorsList[im], marker = None,linestyle=':') # print 'Method',method, 'nKmax',methnKmax, 'avgLogCost', mean(avgcostLogs) legend(loc='lower left',prop={'size':12}); fig.savefig('{}/methodErrs'.format(summaryPath)) close('all') if maxNk > 1: return [methodCostsLogs[0],mean(data['nDone'])] #there is only one method when running this routine else: return [100,0]
d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and d == filter2 ]) nStructs = len(structs) print structs, path for istruct, struct in enumerate(structs): # print 'test', istruct, struct # print 'struct',struct os.chdir(struct) calcs = sorted([ d for d in os.listdir(os.getcwd()) if os.path.isdir(d) and os.path.exists('{}/OUTCAR'.format(d)) ]) if coloring == 'indiv': # if iplot < nplots -1: color = rgb2hex(cm.jet(1. * (iplot + 1) / float(nplots))) # else: # color = 'k' elif coloring == 'method': # color = colorsList[ipath] color = None energies = [] nKs = [] ns = [] #the base n of the run run nDone = 0 if useSym: try: nops, IBZvolcut, IBZvol = readSym(calcs[0]) except: sys.exit('Stopping. readSym failed. Set useSym to False')
num_concepts = len(concepts) root = int(sqrt(num_concepts)) if root * root >= num_concepts: columns = root rows = root elif root * (root + 1) >= num_concepts: columns = root + 1 rows = root else: columns = root + 1 rows = root # for each concept, create a colored scatter plot of all unlabeled data points counter = 1 for label, memberships in validation_memberships.items(): colors = cm.jet(memberships) colmap = cm.ScalarMappable(cmap=cm.jet) colmap.set_array(memberships) ax = fig.add_subplot(rows, columns, counter) if ltn.default_type == "cuboid": # also plot the actual box import matplotlib.patches as patches import shapely.geometry from matplotlib.path import Path def _path_for_core(cuboids, d1, d2): """Creates the 2d path for a complete core.""" polygon = None for cuboid in cuboids:
#Case 3 ---------------------------------------------- #vary the growth rate of organism 1 model = Case3() #create a simulation object instance figure() #create new figure window #create some values for the growth rate of organism 1 r1_vals = linspace(0.5, 3, 10) max_i = len(r1_vals)-1 #do simulations with the different parameter values, plot results for i, r1 in enumerate(r1_vals): model.init_r1(r1) #Use alternative initialization function to supply parameter model.simulateDynamic() #solve ODE res = model.getResults() #get results as a storage.DictStore object color_tuple = cm.jet(i/max_i) label_str = 'r1=%g' % r1 #create descriptive string plot(res['time'], res['m.N1'], label='N1: '+label_str, color=color_tuple, linestyle='-') plot(res['time'], res['m.N2'], label='N2: '+label_str, color=color_tuple, linestyle='--') #finishing touches on plot xlabel('time') ylabel('N1, N2') legend() title('Competition of two species; case 3.') #Case 4 ---------------------------------------------- #vary the growth rate of organism 1 model = Case4() #create a simulation object instance
# first, create a figure. fig = figure() # background color will be used for 'wet' areas. fig.add_axes([0.1, 0.1, 0.8, 0.8], axisbg='aqua') # draw colored markers. # use zorder=10 to make sure markers are drawn last. # (otherwise they are covered up when continents are filled) #m.scatter(x,y,25,z,cmap=cm.jet,marker='o',faceted=False,zorder=10) # create a list of strings containing z values # or, plot actual numbers as color-coded text strings. zn = ['%2i' % zz for zz in z] # plot numbers on map, colored by value. for numstr, zval, xpt, ypt in zip(zn, z, x, y): # only plot values inside map region. if xpt > m.xmin and xpt < m.xmax and ypt > m.ymin and ypt < m.ymax: hexcolor = rgb2hex(cm.jet(zval / 100.)[:3]) text(xpt, ypt, numstr, fontsize=9, weight='bold', color=hexcolor) # draw coasts and fill continents. m.drawcoastlines(linewidth=0.5) m.fillcontinents(color='coral') # draw parallels and meridians. delat = 20. circles = arange(0.,90.,delat).tolist()+\ arange(-delat,-90,-delat).tolist() m.drawparallels(circles) delon = 45. meridians = arange(0, 360, delon) m.drawmeridians(meridians, labels=[1, 1, 1, 1]) title('Random Points', y=1.075) show()
# first, create a figure. fig=figure() # background color will be used for 'wet' areas. fig.add_axes([0.1,0.1,0.8,0.8],axisbg='aqua') # draw colored markers. # use zorder=10 to make sure markers are drawn last. # (otherwise they are covered up when continents are filled) #m.scatter(x,y,25,z,cmap=cm.jet,marker='o',faceted=False,zorder=10) # create a list of strings containing z values # or, plot actual numbers as color-coded text strings. zn = [ '%2i' % zz for zz in z ] # plot numbers on map, colored by value. for numstr,zval,xpt,ypt in zip(zn,z,x,y): # only plot values inside map region. if xpt > m.xmin and xpt < m.xmax and ypt > m.ymin and ypt < m.ymax: hexcolor = rgb2hex(cm.jet(zval/100.)[:3]) text(xpt,ypt,numstr,fontsize=9,weight='bold',color=hexcolor) # draw coasts and fill continents. m.drawcoastlines(linewidth=0.5) m.fillcontinents(color='coral') # draw parallels and meridians. delat = 20. circles = arange(0.,90.,delat).tolist()+\ arange(-delat,-90,-delat).tolist() m.drawparallels(circles) delon = 45. meridians = arange(0,360,delon) m.drawmeridians(meridians,labels=[1,1,1,1]) title('Random Points',y=1.075) show()