def configure_ax(ax): plot_polygon(ax, pughpolygon(rmem=100.), linewidth=lw) ax.set_aspect("equal") ax.set_xlim([-20., 20.]) ax.set_ylim([-33., 40]) ax.set_axis_off() # <=> plt.axis("off") ax.get_xaxis().set_visible(False) # so that white space disappears! ax.get_yaxis().set_visible(False)
gs=gridspec.GridSpec(1, 2, width_ratios=[1,1]) ax0=plt.subplot(gs[0]) plt.title('Current') ax=plt.gca() ax.set_aspect('equal') ax.set_xlim([-20.,20.]) ax.set_ylim([-23.,24.]) ax.set_xticks(np.arange(-20.,20.,2.)) ax.set_yticks(np.arange(-23.,24.,2.)) ax.grid() data = ax0.imshow(matrix1,cmap=plt.cm.viridis,interpolation='none',**args) cbar = fig.colorbar(data) plot_polygon(ax,poly) ax1=plt.subplot(gs[1]) plt.title('Drop') ax=plt.gca() ax.set_aspect('equal') ax.set_xlim([-20.,20.]) ax.set_ylim([-23.,24.]) ax.set_xticks(np.arange(-20.,20.,2.)) ax.set_yticks(np.arange(-23.,24.,2.)) ax.grid() data = ax1.imshow(matrix2,cmap=plt.cm.viridis,interpolation='none',**args) cbar = fig.colorbar(data)
plt.legend(patches, labels, scatterpoints=1, loc=(.43, .12)) ax = plt.gca() ax.set_aspect("equal") ax.set_xlim([-20., 60.]) ax.set_ylim([-25., 35.5]) ax.set_axis_off() # <=> plt.axis("off") ax.get_xaxis().set_visible(False) # so that white space disappears! ax.get_yaxis().set_visible(False) #ax.set_xticks([]) #ax.set_yticks([]) #plt.axis('off') plot_polygon(ax, pughpolygon(rmem=100.), linewidth=lw) plt.axes([.6, .45, .3, .3]) #plt.title('Current $A/I_0$') plt.title("Current signal") ax = plt.gca() if tau_off < 1e3: #t = np.linspace(0., tau_off, 3) fac = 1. #ax.set_xlabel("Time [ns]") elif tau_off < 1e6 and tau_off >= 1e3: #t = np.linspace(0., tau_off*1e-3, 3) fac = 1e-3 #ax.set_xlabel(u"Time [µs]") else:
# obtain 2D mesh where we will evaluate field rx, ry = pughpore.params["R"], 0.5 * pughpore.params["H"] rx, ry = 15, 28 Nx, Ny = 201, 401 #mesh2D = RectangleMesh([-R,-H/2.], [R, H/2.], int(4*R), int(2*H)) Y, X = np.mgrid[-ry:ry:Ny * 1j, -rx:rx:Nx * 1j] U = np.zeros((Ny, Nx)) for y in range(Ny): for x in range(Nx): U[y][x] = F(X[y][x], Y[y][x]) fig, ax = plt.subplots(figsize=(1.73, 1.9)) #, dpi=300) pc = plt.pcolor(X, Y, U, cmap=plt.get_cmap("bone"), vmin=0, vmax=1) plot_polygon(ax, pughpolygon(diamPore=6., rmem=15), linewidth=0.2) plt.xlim(-15, 15) plt.ylim(-25, 28) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) bbox = ax.get_position() l, b, h = bbox.x0, bbox.y0, bbox.height w = 0.05 cbaxes = fig.add_axes([l - w - 0.07, b, w, h]) cb = plt.colorbar(pc, cax=cbaxes, ax=ax) cbaxes.set_ylabel("Rel. diffusivity") # (r"$D_{zz} / D_0$") cb.set_ticks([0., 1.]) cb.set_ticklabels([0, 1]) cbaxes.yaxis.set_ticks_position('left') cbaxes.yaxis.set_label_position('left') cbaxes.yaxis.labelpad = -3.
def save_fig_traj(params,fieldsname,i,showtraj): data=f.get_fields(fieldsname,**params) b1 =data["b1"] b2 =data["b2"] if showtraj: X = data["X"][i] Y = data["Y"][i] Z = data["Z"][i] T = data["T"][i] J = data["J"][i] J=J.load() T=T.load() curr = 7.523849e-10 bind1 = np.where(T>1e6)[0] bind2 = np.intersect1d(np.where(T<=1e6)[0],np.where(T>100.)[0]) amplitude = curr-np.inner(J,T)/np.sum(T) for k in range(1,T.shape[0]): T[k]=T[k]+T[k-1] tau_off=T[-1] J=J*1e12 figname = fieldsname+'_traj_'+'%.8f'%(tau_off*1e-6)+'_%04d'%i+'_%.1e_%.1e_%.1e_%.1e'%(params["avgbind1"],params["avgbind2"],params["P_bind1"],params["P_bind2"])+str(params["z0"]) else: figname = fieldsname+'_bindzones'+'_%.1e_%.1e_%.1e_%.1e'%(params["avgbind1"],params["avgbind2"],params["P_bind1"],params["P_bind2"])+str(params["z0"]) if showtraj: fig=plt.figure(figsize=(8,5),dpi=80) else: fig=plt.figure(figsize=(3,5),dpi=80) color2='#ff0000' color1='#ff9900' color3='#00ff00' #b1 = [[[l1/2.,17.],[l1/2.,19.]],[[l3/2.,-hpore/2.],[l3/2.,hpore/2.-h2],[l2/2.,hpore/2.-h2],[l2/2.,14.]]] for seq in b1: x= [p[0] for p in seq] xm=[-p[0] for p in seq] y= [p[1] for p in seq] plt.plot(x,y,color=color1,linewidth=2.) plt.plot(xm,y,color=color1,linewidth=2.) #b2 = [[[l3/2.-.5,-3.],[l3/2.-.5,11.]]] for seq in b2: x= [p[0] for p in seq] xm=[-p[0] for p in seq] y= [p[1] for p in seq] plt.plot(x,y,color=color2,linewidth=2.) plt.plot(xm,y,color=color2,linewidth=2.) if showtraj: plt.plot(X,Z,linewidth=1.,c='#0000ff') longer = plt.scatter(X[bind1],Z[bind1],s=200,marker='h',c=color2,linewidth=0.) shorter = plt.scatter(X[bind2],Z[bind2],s=100,marker='h',c=color1,linewidth=0.) start = plt.scatter([X[0]],[Z[0]],s=200,marker='x',c=color3,linewidth=2.) patches=[start] labels=['Start'] if showtraj and len(bind1)>0: patches=patches+[longer] labels+=['Longer bindings'] if showtraj and len(bind2)>0: patches=patches+[shorter] labels+=['Shorter bindings'] if showtraj: plt.legend(patches,labels,scatterpoints=1,loc=(.42,.15)) ax=plt.gca() ax.set_aspect('equal') if showtraj: ax.set_xlim([20.,-55.]) ax.set_ylim([-25.,40.]) else: ax.set_xlim([20.,-20.]) ax.set_ylim([-25.,40.]) ax.set_xticks([]) ax.set_yticks([]) plt.axis('off') plot_polygon(ax,polygon(rmem=60.)) if showtraj: plt.axes([.55,.5,.2,.3]) plt.title('Current signal') ax=plt.gca() if tau_off<1e3: t = np.linspace(0.,tau_off,3) fac=1. ax.set_xlabel('time [$ns$]') elif tau_off<1e6 and tau_off>=1e3: t = np.linspace(0.,tau_off*1e-3,3) fac = 1e-3 ax.set_xlabel(r'time [$\mu s$]') else: t = np.linspace(0.,tau_off*1e-6,3) fac = 1e-6 ax.set_xlabel('time [$ms$]') T=T*fac plt.plot(T,J,color='#000000') yt = np.linspace(580.,760,4) ax.set_ylabel(r'A [$pA$]') ax.set_yticks(yt) ax.set_xticks(t) xfmt=FormatStrFormatter('%.1f') ax.xaxis.set_major_formatter(xfmt) ax.set_xlim([-4e-2*tau_off*fac,(1.+4e-2)*tau_off*fac]) plt.tight_layout() # nano.savefigs(name=figname,DIR='/home/bstadlbau/plots/') plt.show() print 'savefig: %s'%figname plt.close("all")
def save_frame(r, X=X, Z=Z, T=T, J=J, curr=curr * 1e12): figname = 'frames/' + '%08d' % r suffix = '.eps' figname += suffix fig = plt.figure(figsize=(32, 18), dpi=120) color2 = '#ff0000' color1 = '#ff9900' color3 = '#00ff00' #b1 = [[[l1/2.,17.],[l1/2.,19.]],[[l3/2.,-hpore/2.],[l3/2.,hpore/2.-h2],[l2/2.,hpore/2.-h2],[l2/2.,14.]]] for seq in b1: x = [p[0] for p in seq] xm = [-p[0] for p in seq] y = [p[1] for p in seq] plt.plot(x, y, color=color1, linewidth=3.) plt.plot(xm, y, color=color1, linewidth=3.) #b2 = [[[l3/2.-.5,-3.],[l3/2.-.5,11.]]] for seq in b2: x = [p[0] for p in seq] xm = [-p[0] for p in seq] y = [p[1] for p in seq] plt.plot(x, y, color=color2, linewidth=3.) plt.plot(xm, y, color=color2, linewidth=3.) plt.plot(X[:r], Z[:r], linewidth=2., c='#0000ff') molecolor = '#33ff99' molecule = plt.Circle((X[r - 1], Z[r - 1]), 2.0779, color=molecolor) mole2 = Line2D(range(1), range(1), color='white', marker='o', markerfacecolor=molecolor, markersize=20) longer = plt.scatter(X[bind1], Z[bind1], s=200, marker='h', c=color2, linewidth=0.) shorter = plt.scatter(X[bind2], Z[bind2], s=100, marker='h', c=color1, linewidth=0.) start = plt.scatter([X[0]], [Z[0]], s=400, marker='x', c=color3, linewidth=2.) patches = [start, mole2] labels = ['Start', 'Molecule'] plt.legend(patches, labels, scatterpoints=1, loc=(.47, .15), fontsize=fs, numpoints=1) ax = plt.gca() ax.add_artist(molecule) ax.set_aspect('equal') ax.set_xlim([47., -82.]) ax.set_ylim([-30., 40.]) ax.set_xticks([]) ax.set_yticks([]) plt.axis('off') plot_polygon(ax, polygon(rmem=100.)) plt.axes([.55, .5, .3, .4]) plt.title('Current signal', fontsize=fs) ax = plt.gca() if tau_off < 1e3: t = np.linspace(0., tau_off, 3) fac = 1. ax.set_xlabel('time [$ns$]', fontsize=fs) elif tau_off < 1e6 and tau_off >= 1e3: t = np.linspace(0., tau_off * 1e-3, 3) fac = 1e-3 ax.set_xlabel(r'time [$\mu s$]', fontsize=fs) else: t = np.linspace(0., tau_off * 1e-6, 3) fac = 1e-6 ax.set_xlabel('time [$ms$]', fontsize=fs) T = T * fac plt.plot(T[:r], J[:r], color='#000000', linewidth=2.) b, a = bessel(3, 2e-5, analog=False) # sig = filtfilt(b,a,J-curr)+curr sig = lfilter(b, a, lfilter(b, a, J - curr)) + curr # plt.plot(T[:r],sig[:r]) yt = np.linspace(580., 760, 4) ax.set_ylabel(r'A [$pA$]', fontsize=fs) ax.set_yticks(yt) ax.set_xticks(t) xfmt = FormatStrFormatter('%.1f') ax.xaxis.set_major_formatter(xfmt) ax.set_xlim([-4e-2 * tau_off * fac, (1. + 4e-2) * tau_off * fac]) plt.tight_layout() # plt.show() plt.savefig(figname) print 'save: ' + figname + ' from %08d' % len plt.close('all')
return D3D([-x, z]) / D0 #D = uCross(u=D3D, axis=1, degree=1, dim=2) # obtain 2D mesh where we will evaluate field rx, ry = pugh.pughpore.params["R"], 0.5 * pugh.pughpore.params["H"] rx, ry = 13, 28 Nx, Ny = 201, 401 #mesh2D = RectangleMesh([-R,-H/2.], [R, H/2.], int(4*R), int(2*H)) Y, X = np.mgrid[-ry:ry:Ny * 1j, -rx:rx:Nx * 1j] U = np.zeros((Ny, Nx)) for y in range(Ny): for x in range(Nx): U[y][x] = F(X[y][x], Y[y][x]) fig, ax = plt.subplots(figsize=(6.5, 6.5), num="r0.11") pc = plt.pcolor(X, Y, U, cmap=cm.inferno, vmin=0, vmax=1) plt.colorbar(pc) plot_polygon(ax, pugh.polygon(diamPore=6., rmem=13)) plt.xlim(-13, 13) plt.ylim(-25, 28) #plt.xlabel("x [nm]") #plt.ylabel("z [nm]") fig.axes[1].set_ylabel(r"$D_{zz} / D_0$") #cb = fig.colorbar(CS, cax=cax, extend="both", orientation="vertical", format=formt) import folders nanopores.savefigs("pugh_Dfield_protein", folders.FIGDIR) plt.show()