From eefbe3b075e2c69638faa4a6c094a504a152a4a0 Mon Sep 17 00:00:00 2001 From: Pu Du Date: Tue, 19 Jun 2018 21:36:07 -0500 Subject: [PATCH] add plotting for ic --- order/plot.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/order/plot.py b/order/plot.py index 86287e2..510385a 100644 --- a/order/plot.py +++ b/order/plot.py @@ -19,12 +19,12 @@ def __init__(self, filename, taskname): base = os.path.basename(filename) self.fprefix = os.path.splitext(base)[0] self.taskname = taskname - self.data = np.loadtxt(self.fprefix+'_'+self.taskname+'.dat') #self.plot_distribution() def plot_distribution(self): """plot distribution""" + data = np.loadtxt(self.fprefix+'_'+self.taskname+'.dat') #plot setting #plt.rcParams['font.family'] = 'serif' #plt.rcParams['font.serif'] = 'Ubuntu' @@ -56,17 +56,20 @@ def plot_distribution(self): plt.xlabel('t') plt.ylabel('') - x = self.data[:,0] - y = self.data[:,1] + x = data[:,0] + y = data[:,1] plt.plot(x,y,linewidth=2.0) figure = self.fprefix + '_' + self.taskname.upper() + '.pdf' plt.savefig(figure, bbox_inches="tight") - def plot_ionic(self, t_unit): + def plot_ionic(self): """plot distribution""" + data1 = np.loadtxt(self.fprefix+'_'+self.taskname+'_ti.dat') + data2 = np.loadtxt(self.fprefix+'_'+self.taskname+'_iaafp.dat') + #plot setting #plt.rcParams['font.family'] = 'serif' #plt.rcParams['font.serif'] = 'Ubuntu' @@ -82,19 +85,19 @@ def plot_ionic(self, t_unit): #clean last plot plt.clf() - plt.xlabel("Simulation time({})".format(t_unit)) - plt.ylabel("Charge from ions crossing the plane") - - x = self.data[:,0] - y = self.data[:,1] + plt.xlabel("Simulation time(ps)") + plt.ylabel("Charge from ions crossing the plane (e)") - slope, intercept, r_value, p_value, std_err = stats.linregress(x,y) + x1 = data1[:,0] + y1 = data1[:,1] - y_fit = slope * x + intercept + x2 = data2[:,0] + y2 = data2[:,1] - plt.plot(x, y, '.') - plt.plot(x, y_fit, '-') + plt.plot(x1, y1, label='ti') + plt.plot(x2, y2, label='iaafp') + plt.legend() figure = self.fprefix + '_' + self.taskname.upper() + '.pdf' plt.savefig(figure, bbox_inches="tight") \ No newline at end of file