Skip to content

Commit

Permalink
add plotting for ic
Browse files Browse the repository at this point in the history
  • Loading branch information
ipudu committed Jun 20, 2018
1 parent b7604c5 commit eefbe3b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions order/plot.py
Expand Up @@ -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'
Expand Down Expand Up @@ -56,17 +56,20 @@ def plot_distribution(self):
plt.xlabel('t')
plt.ylabel('<r^2>')

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'
Expand All @@ -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")

0 comments on commit eefbe3b

Please sign in to comment.