Beispiel #1
0
    def plotAndSaveToFile(self, outFile = 'bandstructure.pdf', silent_overwrite = False, **kwargs):
            

        import matplotlib
        matplotlib.use("pdf")
        from oppvasp.plotutils import prepare_canvas
        from matplotlib import rc
        rc('lines', linewidth=0.5)
        rc('font',**{'family':'serif','serif':['Palatino']})
        rc('font', family='serif')
        rc('text', usetex=True)
        prepare_canvas('10 cm')
        fig = plt.figure()
        p = [0.15, 0.15, 0.05, 0.05]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        ax0 = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
        self.plot(ax0, **kwargs)
        # Write to file:
        if not silent_overwrite and os.path.exists(outFile):
            print "\nWARNING: The file \"%s\" already exists." % outFile
            if query_yes_no("         Do you want to overwrite it?") == 'no':
                return

        sys.stdout.write("\nSaving band structure to %s... " % outFile)
        sys.stdout.flush()
        plt.savefig(outFile)
        sys.stdout.write("done!\n\n")
Beispiel #2
0
    def plotAndSaveToFile(self,
                          outFile='bandstructure.pdf',
                          silent_overwrite=False,
                          **kwargs):

        import matplotlib
        matplotlib.use("pdf")
        from oppvasp.plotutils import prepare_canvas
        from matplotlib import rc
        rc('lines', linewidth=0.5)
        rc('font', **{'family': 'serif', 'serif': ['Palatino']})
        rc('font', family='serif')
        rc('text', usetex=True)
        prepare_canvas('10 cm')
        fig = plt.figure()
        p = [0.15, 0.15, 0.05, 0.05
             ]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        ax0 = fig.add_axes([p[0], p[1], 1 - p[2] - p[0], 1 - p[3] - p[1]])
        self.plot(ax0, **kwargs)
        # Write to file:
        if not silent_overwrite and os.path.exists(outFile):
            print "\nWARNING: The file \"%s\" already exists." % outFile
            if query_yes_no("         Do you want to overwrite it?") == 'no':
                return

        sys.stdout.write("\nSaving band structure to %s... " % outFile)
        sys.stdout.flush()
        plt.savefig(outFile)
        sys.stdout.write("done!\n\n")
 def plot_to_file(self,outfile):
     import matplotlib
     matplotlib.use('pdf')
     from oppvasp.plotutils import prepare_canvas
     prepare_canvas('8 cm')
     import matplotlib.pyplot as plt
     fig = plt.figure()
     ax = fig.add_subplot(1,1,1)
     fig.subplots_adjust(left=0.17, bottom=0.20, right=0.80, top=0.95)
     self.plot(ax)
     plt.savefig(outfile)
 def plot_to_file(self, outfile):
     import matplotlib
     matplotlib.use('pdf')
     from oppvasp.plotutils import prepare_canvas
     prepare_canvas('8 cm')
     import matplotlib.pyplot as plt
     fig = plt.figure()
     ax = fig.add_subplot(1, 1, 1)
     fig.subplots_adjust(left=0.17, bottom=0.20, right=0.80, top=0.95)
     self.plot(ax)
     plt.savefig(outfile)
Beispiel #5
0
    def plot_to_file(self, outfile = '', verbose = False):

        if not self.valid:
            return
        print "[DistanceFromLatticeSites] Plotting..."

        import matplotlib
        matplotlib.use('pdf')
        prepare_canvas('10 cm')
        import matplotlib.pyplot as plt
        fig = plt.figure()
        ax = fig.add_subplot(1,1,1)
        self.plot(ax, verbose = verbose)

        if outfile == '':
            outfile = os.path.splitext(sys.argv[0])[0] + '.pdf'
        sys.stdout.write("Writing %s... " % os.path.basename(outfile))
        sys.stdout.flush()
        plt.savefig(outfile)
        sys.stdout.write("done!\n")
Beispiel #6
0
    'alpha': 0.2
}, {
    'color': 'green',
    'alpha': 0.2
}, {
    'color': 'blue',
    'alpha': 0.2
}, {
    'color': 'black'
}, {
    'color': 'green'
}, {
    'color': 'blue'
}]

prepare_canvas('10 cm')
fig = plt.figure()

# Main plot:
p = [0.15, 0.15, 0.05,
     0.05]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
ax1 = fig.add_axes([p[0], p[1], 1 - p[2] - p[0], 1 - p[3] - p[1]])
ax1.grid(True, which='major', color='gray', alpha=0.5)
ax1.set_ylim((-.2, 1.0))
ax1.set_xlabel('Time [ps]')
ax1.set_ylabel('$\lambda$')
ax1.plot(traj.time[0:nsteps] / 1.e3, T1, **styles[0])
ax1.plot(traj.time[0:nsteps] / 1.e3, T2, **styles[1])
ax1.plot(traj.time[0:nsteps] / 1.e3, T3, **styles[2])
ax1.plot(traj.time[0:nsteps] / 1.e3, T1m, label='T1', **styles[3])
ax1.plot(traj.time[0:nsteps] / 1.e3, T2m, label='T2', **styles[4])
#lambda_t =  1./3 * (lambda_x + lambda_y + lambda_z) 
#print "Initial lattice integrity:",lambda_t[0]

#############################################################################
# (2) Plot

styles = [
        { 'color': 'black', 'alpha': 0.2 },
        { 'color': 'green', 'alpha': 0.2 },
        { 'color': 'blue', 'alpha': 0.2 },
        { 'color': 'black' },
       { 'color': 'green' },
       { 'color': 'blue' }
   ]

prepare_canvas('10 cm') 
fig = plt.figure()

# Main plot:
p = [0.15, 0.15, 0.05, 0.05]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
ax1 = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
ax1.grid(True, which='major', color = 'gray', alpha = 0.5)
ax1.set_ylim((-.2,1.0))
ax1.set_xlabel('Time [ps]')
ax1.set_ylabel('$\lambda$')
ax1.plot(traj.time[0:nsteps]/1.e3, T1, **styles[0])
ax1.plot(traj.time[0:nsteps]/1.e3, T2, **styles[1])
ax1.plot(traj.time[0:nsteps]/1.e3, T3, **styles[2])
ax1.plot(traj.time[0:nsteps]/1.e3, T1m, label = 'T1', **styles[3])
ax1.plot(traj.time[0:nsteps]/1.e3, T2m, label = 'T2', **styles[4])
ax1.plot(traj.time[0:nsteps]/1.e3, T3m, label = 'T3', **styles[5])
    def plot_to_file(self, fig_filename=''):
        """
        Automatic plot method. This method is not very robust, and should in general be modified 
        to highlight the points of interest.
        """
        styles = [
            {
                'color': 'black'
            },
            {
                'color': 'gray',
                'alpha': .5
            },  # dashes: (ink on, ink off)
            {
                'color': 'gray',
                'linestyle': '--',
                'dashes': (6, 2),
                'alpha': .5
            },  # dashes: (ink on, ink off)
            {
                'color': 'blue'
            }
        ]
        prepare_canvas('10 cm')
        fig = plt.figure()

        #
        #ax1.set_ylabel(u'Distance [Å]')
        #ax1.set_xlabel('Time [ps]')
        #print self.occ.shape
        #print self.occ
        #plt.pcolor(C, cmap=mpl.cm.gray_r )
        # http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo2.html
        #p = [0.15, 0.15, 0.05, 0.52]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        #ax1 = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
        #norm = mpl.colors.Normalize(vmin=0, vmax=3)
        #im = ax1.imshow(self.occ.T, cmap=mpl.cm.gray_r, norm=norm, aspect='auto', interpolation='nearest')

        nsteps = self.occ.shape[0]
        nsites = self.occ.shape[1]
        natoms = self.traj.num_atoms

        lw = 10.

        #
        p = [0.15, 0.05, 0.05, 0.05
             ]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        ax2 = fig.add_axes([p[0], p[1], 1 - p[2] - p[0], 1 - p[3] - p[1]])
        #print self.vel.shape
        #ax2.acorr(self.vel[:,0,0],usevlines=True, lw=2)
        #norm2 = mpl.colors.Normalize(vmin=0, vmax=natoms)

        maxocc = 1
        imgrid = np.ones(
            (nsteps, nsites * maxocc * lw, 3))  # RGB float32 array

        colors = np.ones((natoms, 3)) * .9  # default atom color
        colors[0] = [1., 0., 0.]  # color for atom 0

        print self.occ.shape
        print self.inhabitants.shape
        print imgrid.shape
        for i in range(self.occ.shape[0]):
            for j in range(self.occ.shape[1]):
                #imgrid[i,j*maxocc*lw:j*maxocc*lw+lw] = colors[self.inhabitants[i,j,0]]
                for k in range(self.occ[i, j]):
                    imgrid[i, (j * maxocc + k) * lw:(j * maxocc + k) * lw +
                           lw] = colors[self.inhabitants[
                               i, j,
                               k]]  # 0,natoms -> 1,natoms+1 so 0=no atoms
                    if k + 1 >= maxocc:
                        print "Warning: Too high occupancy"
                        break
                #    #print (j*4+k)/4., colors[self.inhabitants[i,j,k]]
        im2 = ax2.imshow(np.transpose(imgrid, axes=[1, 0, 2]),
                         aspect='auto',
                         interpolation='nearest')
        #im2.
        #im2 = ax2.imshow(np.transpose(imgrid, axes=[1,0,2]), aspect='auto', interpolation='nearest')
        #ax2.set_ylim(-1*maxocc*lw,nsites*maxocc*lw+maxocc+lw)
        #ax2.minorticks_on()
        #ax2.set_yticks(np.arange(0,64*maxocc*lw,4), minor=True)
        #ax2.set_yticks(np.arange(0,64*4,10*4))
        #ax2.set_yticks([])
        #ax2.minorticks_off()
        #ax1.

        #ticks = ax2.get_yticks()
        #print ticks
        #labels = [ t/4. for t in ticks ]
        #print labels
        #ax2.set_yticklabels(labels)

        #        y_max = 3.
        #        y_sub = .3

        #        prev_site = -1
        #        cur_site = -1
        #        cur_count = 0
        #        n = self.occupancies.shape[0]
        #        for i in range(n):
        #            cur_site = self.followed_atom_site[i,0]
        #            if cur_site != prev_site:
        #                if cur_count*self.step_size > 1000:
        #                    ax1.fill([time[i-cur_count], time[i-cur_count], time[i], time[i]], [y_max,y_max-y_sub,y_max-y_sub,y_max], color = 'green', linewidth=0., alpha = 0.2)
        #                    ax1.text(time[i-cur_count]+(time[i]-time[i-cur_count])/2.,y_max-(y_sub/2.),'%d' % (prev_site), horizontalalignment='center', verticalalignment='center', fontsize = 8)
        #                ax1.axvline(time[i], color = 'red', alpha = 0.5)
        #                cur_count = 0
        #                prev_site = cur_site
        #            cur_count += 1
        ##if label_added:
        ##    ax1.fill([time[i-cur_count+1], time[i-cur_count], time[i], time[i]], [y_max,y_max-y_sub,y_max-y_sub,y_max], color = 'green', linewidth=0., alpha = 0.2)

        #        cur_count-=1
        #        if cur_count*self.step_size > 1000:
        #            ax1.fill([time[i-cur_count], time[i-cur_count], time[i], time[i]], [y_max,y_max-y_sub,y_max-y_sub,y_max], color = 'green', linewidth=0., alpha = 0.2)
        #            ax1.text(time[i-cur_count]+(time[i]-time[i-cur_count])/2.,y_max-(y_sub/2.),'%d' % (prev_site), horizontalalignment='center', verticalalignment='center', fontsize = 8)

        if fig_filename == '':
            fig_filename = os.path.splitext(sys.argv[0])[0] + '.pdf'
        sys.stdout.write("Writing %s... " % os.path.basename(fig_filename))
        sys.stdout.flush()
        plt.savefig(fig_filename)
        sys.stdout.write("done!\n")

        print
Beispiel #9
0
# min/max x:
r_min = 0
r_max = 5000


#############################################################################
# (2) Plot

styles = [
        { 'color': 'gray', 'alpha': .5 },
        { 'color': 'black', 'linestyle': '--', 'dashes': (4,1), 'alpha': .8 }, # dashes: (ink on, ink off)
        { 'color': 'black' },
        { 'color': 'gray', 'alpha': .5 } # dashes: (ink on, ink off)
    ]

plotutils.prepare_canvas( width = '7 cm', fontsize = 9, fontsize_small = 8 ) 
fig = plt.figure()

toten = traj.total_energy[r_min:r_max]
toten_ra = plotutils.symmetric_running_mean(toten,250)

# Lower plot
p = [0.20, 0.20, 0.05, 0.52]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
ax0 = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
ax0.plot(traj.time[r_min:r_max]/1.e3, toten, zorder=1, **styles[0])
ax0.plot(traj.time[r_min:r_max]/1.e3, toten_ra, zorder=1, **styles[2])
#ax0.plot(traj.time[r_min:r_max]/1.e3, poten_ra, zorder=1, **styles[1])
ax0.set_xlabel('Time [ps]')
ax0.set_ylabel('$E$ [eV]')
#ax0.set_yticks(np.arange(-340,-300,10))
ymean = np.mean(toten[-500:-1])
    def plot(self):
        """
        Automatic plot method. This method is not very robust, and should in general be modified 
        to highlight the points of interest.
        """
        styles = [
               { 'color': 'black' },
               { 'color': 'gray', 'alpha': .5 }, # dashes: (ink on, ink off)
               { 'color': 'gray', 'linestyle': '--', 'dashes': (6,2), 'alpha': .5 }, # dashes: (ink on, ink off)
               { 'color': 'blue' }
           ]
        prepare_canvas('10 cm')
        fig = plt.figure()

        p = [0.15, 0.57, 0.05, 0.03]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        upper = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
        upper.set_ylabel(u'$r(t)-r(0)$ [Å]')
        upper.set_xticklabels([])

        p = [0.15, 0.15, 0.05, 0.45]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        lower = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
        lower.set_xlabel('Time $t$ [ps]')
        lower.set_ylabel(u'$r(t)-R$ (å)')

        time = self.traj.time[::self.step_size]/1.e3
        y = np.sqrt(self.followed_atom_r2[:,0:self.num_neighbours])

        lower.plot(time, y, **styles[0])
        ticks = [0.]
        ticklabels = [0.]
        for i in range(y.shape[1]):
            lower.axhline(y[0,i], color = 'black', linestyle='dashed', alpha = 0.5)
            print "Y:",y[0,i]
            ticks.append(y[0,i])
            ticklabels.append("%.2f" % (y[0,i]))
        lower.set_yticks(ticks)
        lower.set_yticklabels(ticklabels)

        r = np.sqrt(np.sum((self.pos[::self.step_size,0]-self.pos[0,0])**2, axis=1))

        print time.shape
        print r.shape
        upper.plot(time, r)

        # ================== Paint bottombar ==================================

        prev_site = -1
        cur_site = -1
        cur_count = 0
        n = self.occupancies.shape[0]
        labelled_sites = []
        for i in range(n):
            cur_site = self.followed_atom_site[i,0]
            if cur_site != prev_site and prev_site != -1:
                labelled_sites = self.bottombar_fill(lower, prev_site, time[i-cur_count], time[i], labelled_sites)
                cur_count = 0
            prev_site = cur_site
            cur_count += 1
        
        #cur_count-=1
        labelled_sites = self.bottombar_fill(lower, prev_site, time[-cur_count], time[-1], labelled_sites)

        self.plt = plt
        self.lower = lower
        self.upper = upper
    def plot_to_file(self, fig_filename = ''):
        """
        Automatic plot method. This method is not very robust, and should in general be modified 
        to highlight the points of interest.
        """
        styles = [
               { 'color': 'black' },
               { 'color': 'gray', 'alpha': .5 }, # dashes: (ink on, ink off)
               { 'color': 'gray', 'linestyle': '--', 'dashes': (6,2), 'alpha': .5 }, # dashes: (ink on, ink off)
               { 'color': 'blue' }
           ]
        prepare_canvas('10 cm')
        fig = plt.figure()
        
        #
        #ax1.set_ylabel(u'Distance [Å]')
        #ax1.set_xlabel('Time [ps]')
        #print self.occ.shape
        #print self.occ
        #plt.pcolor(C, cmap=mpl.cm.gray_r )
        # http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo2.html
        #p = [0.15, 0.15, 0.05, 0.52]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        #ax1 = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
        #norm = mpl.colors.Normalize(vmin=0, vmax=3)
        #im = ax1.imshow(self.occ.T, cmap=mpl.cm.gray_r, norm=norm, aspect='auto', interpolation='nearest')

        nsteps = self.occ.shape[0]
        nsites = self.occ.shape[1]
        natoms = self.traj.num_atoms

        lw = 10.
        
        #
        p = [0.15, 0.05, 0.05, 0.05]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        ax2 = fig.add_axes([ p[0], p[1], 1-p[2]-p[0], 1-p[3]-p[1] ])
        #print self.vel.shape
        #ax2.acorr(self.vel[:,0,0],usevlines=True, lw=2)
        #norm2 = mpl.colors.Normalize(vmin=0, vmax=natoms)
        
        maxocc = 1
        imgrid = np.ones((nsteps, nsites*maxocc*lw,3)) # RGB float32 array

        colors=np.ones((natoms,3))*.9   # default atom color
        colors[0] = [1.,0.,0.]          # color for atom 0


        print self.occ.shape
        print self.inhabitants.shape
        print imgrid.shape
        for i in range(self.occ.shape[0]):
            for j in range(self.occ.shape[1]):
                #imgrid[i,j*maxocc*lw:j*maxocc*lw+lw] = colors[self.inhabitants[i,j,0]]
                for k in range(self.occ[i,j]):
                    imgrid[i,(j*maxocc+k)*lw:(j*maxocc+k)*lw+lw] = colors[self.inhabitants[i,j,k]] # 0,natoms -> 1,natoms+1 so 0=no atoms
                    if k+1 >= maxocc:
                        print "Warning: Too high occupancy"
                        break
                #    #print (j*4+k)/4., colors[self.inhabitants[i,j,k]]
        im2 = ax2.imshow(np.transpose(imgrid, axes=[1,0,2]), aspect='auto', interpolation='nearest')
        #im2.
        #im2 = ax2.imshow(np.transpose(imgrid, axes=[1,0,2]), aspect='auto', interpolation='nearest')
        #ax2.set_ylim(-1*maxocc*lw,nsites*maxocc*lw+maxocc+lw)
        #ax2.minorticks_on()
        #ax2.set_yticks(np.arange(0,64*maxocc*lw,4), minor=True)
        #ax2.set_yticks(np.arange(0,64*4,10*4))
        #ax2.set_yticks([])
        #ax2.minorticks_off()
        #ax1.


        #ticks = ax2.get_yticks()
        #print ticks
        #labels = [ t/4. for t in ticks ]
        #print labels
        #ax2.set_yticklabels(labels)

        

#        y_max = 3.
#        y_sub = .3

#        prev_site = -1
#        cur_site = -1
#        cur_count = 0
#        n = self.occupancies.shape[0]
#        for i in range(n):
#            cur_site = self.followed_atom_site[i,0]
#            if cur_site != prev_site:
#                if cur_count*self.step_size > 1000:
#                    ax1.fill([time[i-cur_count], time[i-cur_count], time[i], time[i]], [y_max,y_max-y_sub,y_max-y_sub,y_max], color = 'green', linewidth=0., alpha = 0.2)
#                    ax1.text(time[i-cur_count]+(time[i]-time[i-cur_count])/2.,y_max-(y_sub/2.),'%d' % (prev_site), horizontalalignment='center', verticalalignment='center', fontsize = 8)
#                ax1.axvline(time[i], color = 'red', alpha = 0.5)
#                cur_count = 0
#                prev_site = cur_site
#            cur_count += 1
##if label_added:
##    ax1.fill([time[i-cur_count+1], time[i-cur_count], time[i], time[i]], [y_max,y_max-y_sub,y_max-y_sub,y_max], color = 'green', linewidth=0., alpha = 0.2)

#        cur_count-=1
#        if cur_count*self.step_size > 1000:
#            ax1.fill([time[i-cur_count], time[i-cur_count], time[i], time[i]], [y_max,y_max-y_sub,y_max-y_sub,y_max], color = 'green', linewidth=0., alpha = 0.2)
#            ax1.text(time[i-cur_count]+(time[i]-time[i-cur_count])/2.,y_max-(y_sub/2.),'%d' % (prev_site), horizontalalignment='center', verticalalignment='center', fontsize = 8)


        if fig_filename == '':
            fig_filename = os.path.splitext(sys.argv[0])[0] + '.pdf'
        sys.stdout.write("Writing %s... " % os.path.basename(fig_filename))
        sys.stdout.flush()
        plt.savefig(fig_filename)
        sys.stdout.write("done!\n")

        print
Beispiel #12
0
    def plot(self):
        """
        Automatic plot method. This method is not very robust, and should in general be modified 
        to highlight the points of interest.
        """
        styles = [
            {
                'color': 'black'
            },
            {
                'color': 'gray',
                'alpha': .5
            },  # dashes: (ink on, ink off)
            {
                'color': 'gray',
                'linestyle': '--',
                'dashes': (6, 2),
                'alpha': .5
            },  # dashes: (ink on, ink off)
            {
                'color': 'blue'
            }
        ]
        prepare_canvas('10 cm')
        fig = plt.figure()

        p = [0.15, 0.57, 0.05, 0.03
             ]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        upper = fig.add_axes([p[0], p[1], 1 - p[2] - p[0], 1 - p[3] - p[1]])
        upper.set_ylabel(u'$r(t)-r(0)$ [Å]')
        upper.set_xticklabels([])

        p = [0.15, 0.15, 0.05, 0.45
             ]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
        lower = fig.add_axes([p[0], p[1], 1 - p[2] - p[0], 1 - p[3] - p[1]])
        lower.set_xlabel('Time $t$ [ps]')
        lower.set_ylabel(u'$r(t)-R$ (å)')

        time = self.traj.time[::self.step_size] / 1.e3
        y = np.sqrt(self.followed_atom_r2[:, 0:self.num_neighbours])

        lower.plot(time, y, **styles[0])
        ticks = [0.]
        ticklabels = [0.]
        for i in range(y.shape[1]):
            lower.axhline(y[0, i],
                          color='black',
                          linestyle='dashed',
                          alpha=0.5)
            print "Y:", y[0, i]
            ticks.append(y[0, i])
            ticklabels.append("%.2f" % (y[0, i]))
        lower.set_yticks(ticks)
        lower.set_yticklabels(ticklabels)

        r = np.sqrt(
            np.sum((self.pos[::self.step_size, 0] - self.pos[0, 0])**2,
                   axis=1))

        print time.shape
        print r.shape
        upper.plot(time, r)

        # ================== Paint bottombar ==================================

        prev_site = -1
        cur_site = -1
        cur_count = 0
        n = self.occupancies.shape[0]
        labelled_sites = []
        for i in range(n):
            cur_site = self.followed_atom_site[i, 0]
            if cur_site != prev_site and prev_site != -1:
                labelled_sites = self.bottombar_fill(lower, prev_site,
                                                     time[i - cur_count],
                                                     time[i], labelled_sites)
                cur_count = 0
            prev_site = cur_site
            cur_count += 1

        #cur_count-=1
        labelled_sites = self.bottombar_fill(lower, prev_site,
                                             time[-cur_count], time[-1],
                                             labelled_sites)

        self.plt = plt
        self.lower = lower
        self.upper = upper
Beispiel #13
0
    {
        'color': 'black',
        'linestyle': '--',
        'dashes': (4, 1),
        'alpha': .8
    },  # dashes: (ink on, ink off)
    {
        'color': 'black'
    },
    {
        'color': 'gray',
        'alpha': .5
    }  # dashes: (ink on, ink off)
]

plotutils.prepare_canvas(width='7 cm', fontsize=9, fontsize_small=8)
fig = plt.figure()

toten = traj.total_energy[r_min:r_max]
toten_ra = plotutils.symmetric_running_mean(toten, 250)

# Lower plot
p = [0.20, 0.20, 0.05,
     0.52]  # margins: left, bottom, right, top. Height: 1-.15-.46 = .39
ax0 = fig.add_axes([p[0], p[1], 1 - p[2] - p[0], 1 - p[3] - p[1]])
ax0.plot(traj.time[r_min:r_max] / 1.e3, toten, zorder=1, **styles[0])
ax0.plot(traj.time[r_min:r_max] / 1.e3, toten_ra, zorder=1, **styles[2])
#ax0.plot(traj.time[r_min:r_max]/1.e3, poten_ra, zorder=1, **styles[1])
ax0.set_xlabel('Time [ps]')
ax0.set_ylabel('$E$ [eV]')
#ax0.set_yticks(np.arange(-340,-300,10))