def keypress(event): global pos,cb,fig,dataset,nticks,ticks,colors,cmap if event.key==",": pos -= 1 if event.key==".": pos += 10 if event.key=="a": nticks+=1 ticks=[i/float(nticks) for i in range(nticks)] colors=[float2rgb(sqrt(i+1),mic,mxc) for i in range(len(ticks))] if event.key=="z": nticks-=1 ticks=[i/float(nticks) for i in range(nticks)] colors=[float2rgb(sqrt(i+1),mic,mxc) for i in range(len(ticks))] pos=pos%gridsz[0] if pstyle==1: ax=logplotter(X,Y,dataset[pos,:,:],ticks,colors) pl.title("%d Log plot energy density, use < and > to change plots"%pos) #P.colorbar(ax,ticks=ticks,drawedges=True) cb.update_bruteforce(ax) elif pstyle==2: plotter(X,Y,dataset[pos,:,:]) pl.title("%d Vacancy in Red, use < and > to change plots"%pos) elif pstyle==3: pl.imshow(dataset[pos,:,:],extent=[0,gridsz[0],0,gridsz[1]],cmap=cmap) pl.draw()
def keypress(event): global pos, cb, fig, dataset, nticks, ticks, colors, cmap if event.key == ",": pos -= 1 if event.key == ".": pos += 10 if event.key == "a": nticks += 1 ticks = [i / float(nticks) for i in range(nticks)] colors = [float2rgb(sqrt(i + 1), mic, mxc) for i in range(len(ticks))] if event.key == "z": nticks -= 1 ticks = [i / float(nticks) for i in range(nticks)] colors = [float2rgb(sqrt(i + 1), mic, mxc) for i in range(len(ticks))] pos = pos % gridsz[0] if pstyle == 1: ax = logplotter(X, Y, dataset[pos, :, :], ticks, colors) pl.title("%d Log plot energy density, use < and > to change plots" % pos) #P.colorbar(ax,ticks=ticks,drawedges=True) cb.update_bruteforce(ax) elif pstyle == 2: plotter(X, Y, dataset[pos, :, :]) pl.title("%d Vacancy in Red, use < and > to change plots" % pos) elif pstyle == 3: pl.imshow(dataset[pos, :, :], extent=[0, gridsz[0], 0, gridsz[1]], cmap=cmap) pl.draw()
plotter(X,Y,dataset[pos,:,:]) pl.title("%d Vacancy in Red, use < and > to change plots"%pos) elif pstyle==3: pl.imshow(dataset[pos,:,:],extent=[0,gridsz[0],0,gridsz[1]],cmap=cmap) pl.draw() global fig,cb,pos,nticks,ticks,colors,cmap #ticks=[1e-3,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,6.0,7.0,8.0,9.0,10.0,15.0,20.0,25.0,30.0,50.0,70.0,100.0,300.0] nticks=30 mx=max(dataset.ravel()) mn=min(dataset.ravel()) #ticks=[round(i/float(nticks)*(mx-mn)+mn,2) for i in range(nticks)] ticks=[i/float(nticks)*(mx-mn)+mn for i in range(nticks)] mxc=sqrt(len(ticks)+1) mic=0 colors=[float2rgb(sqrt(i+1),mic,mxc) for i in range(len(ticks))] #pl.plot([cutev,cutev],[0,0.5],c="black",lw=3.0) #pl.xlim(0,10) #pl.xlabel("Charge (eV)") #pl.ylabel("Count") #pl.title("Histogram of Charge Density %s"%os.getcwd().split("/")[-1]) if pstyle!=0: fig=pl.figure() #ax=fig.gca() canvas=fig.canvas pos=0 canvas.mpl_connect("key_press_event",keypress) if pstyle==1:
pl.imshow(dataset[pos, :, :], extent=[0, gridsz[0], 0, gridsz[1]], cmap=cmap) pl.draw() global fig, cb, pos, nticks, ticks, colors, cmap #ticks=[1e-3,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,6.0,7.0,8.0,9.0,10.0,15.0,20.0,25.0,30.0,50.0,70.0,100.0,300.0] nticks = 30 mx = max(dataset.ravel()) mn = min(dataset.ravel()) #ticks=[round(i/float(nticks)*(mx-mn)+mn,2) for i in range(nticks)] ticks = [i / float(nticks) * (mx - mn) + mn for i in range(nticks)] mxc = sqrt(len(ticks) + 1) mic = 0 colors = [float2rgb(sqrt(i + 1), mic, mxc) for i in range(len(ticks))] #pl.plot([cutev,cutev],[0,0.5],c="black",lw=3.0) #pl.xlim(0,10) #pl.xlabel("Charge (eV)") #pl.ylabel("Count") #pl.title("Histogram of Charge Density %s"%os.getcwd().split("/")[-1]) if pstyle != 0: fig = pl.figure() #ax=fig.gca() canvas = fig.canvas pos = 0 canvas.mpl_connect("key_press_event", keypress) if pstyle == 1: