def create_contact_lgh_graph(simDirs, legend='None', width=3, xlabel='', ylabel='', show=True, logScale=False, figPath=''): ''' @description: create a graph with the contact length as function of time for different contact angles ''' plt.close("all") plt.rc('text', usetex=True) plt.rc('font', family='serif') fig = plt.figure(figsize=(8,6)) # plot the mass as function of time # as the main plot ax = fig.add_subplot(111) for i in range(0,len(simDirs)): contactLgh = np.loadtxt(os.path.join(simDirs[i],'contact_lgh_n.txt')) # plot the mass as function # of time on the main graph grayscale_value = 0.2+ 0.8*float(i)/float(len(simDirs)) #timeDev = np.empty([len(contactLgh[:,0])-2,2]) # #for j in range(1,len(contactLgh[:,0])-1): # # timeDev[j-1,0] = contactLgh[j-1,1] # # timeDev[j-1,1] = (contactLgh[j+1,2]-contactLgh[j-1,2])/\ # (contactLgh[j+1,1]-contactLgh[j-1,1]) # #plt.plot(timeDev[:,0], # timeDev[:,1], # '-', # linewidth=width, # color=grayscale_to_RGB(grayscale_value)) plt.plot(contactLgh[:,1], contactLgh[:,2], '+-', linewidth=width, color=grayscale_to_RGB(grayscale_value)) ax.set_xlabel(r''+xlabel) ax.set_ylabel(r''+ylabel) if(logScale): #ax.set_xscale('log') ax.set_yscale('log') if(legend!='None'): plt.legend(legend,loc='lower right') ax.set_xlim([0,30]) if(show): plt.show() plt.close() if(not figPath==''): plt.savefig(figPath)
# with two different axis plt.rc('text', usetex=True) plt.rc('font', family='serif') fig = plt.figure(figsize=(8,6)) ax = fig.add_subplot(111) ax.set_xlabel(r'$t$') ax.set_ylabel(r'mass($t$)') ax2 = ax.twinx() ax2.set_ylabel(r'volume($t$)') ax.plot(mass[0:step,1], mass[0:step,2], 'o-', color=grayscale_to_RGB(0.2), linewidth=3) ax2.plot(volume[0:step,1], volume[0:step,2], 's-', color=grayscale_to_RGB(0.8), linewidth=3) # linear interpolation of the mass as # function of time i1 = [11,17] i2 = [16,30] # constant initial stage