Example #1
0
 def plot(self, x=None, y=None, addto=None, linestyle=None,
          linecolor='black', yy=False, xerr=None, yerr=None, legend=True,
          env='plot', axes=None, polar=False):
     if addto is None:
         plot = ahp.pyg2d(env=env, polar=polar);
     else:
         plot = addto;
     if xerr is None:
         xerr = self.u_x
     if yerr is None:
         yerr = self.u_y
     if x is None and y is None:
         x = self.x;
         y = self.y;
     if self.data is 'binned':
         # plot the bins
         # setup a matix
         # preallocate this later ***********************************
         plot_x = np.array([]);
         plot_y = np.array([]);
         # plot the thick bars
         for i in np.arange(0,len(x)-1):
             plot_x = np.append(plot_x,x[i]);
             plot_y = np.append(plot_y,y[i]);
             plot_x = np.append(plot_x,x[i+1]);
             plot_y = np.append(plot_y,y[i]);
             plot_x = np.append(plot_x,np.nan);
             plot_y = np.append(plot_y,np.nan);
             self.binned_data_x = plot_x
             self.binned_data_y = plot_y
         plot.add_line(plot_x,plot_y,name=self.name,linewidth=4.0,linecolor=linecolor,
             linestyle='-', legend=legend);
         conn_x = np.array([]);
         conn_y = np.array([]);
         for i in np.arange(1,len(x)):
             conn_x = np.append(conn_x,x[i]);
             conn_y = np.append(conn_y,y[i-1]);
             conn_x = np.append(conn_x,x[i]);
             conn_y = np.append(conn_y,y[i]);
             conn_x = np.append(conn_x,np.nan);
             conn_y = np.append(conn_y,np.nan);
         plot.add_line(conn_x,conn_y,name=self.name+'connectors',linewidth=0.1,linestyle='-',linecolor=linecolor);
         plot.markers_off();
         plot.lines_on();
     elif self.data is 'smooth':
         if yy is False:
             plot.add_line(x,y,xerr=self.u_x,yerr=self.u_y,name=self.name,linestyle=linestyle,linecolor=linecolor, axes=axes);
         else:
             plot.add_line_yy(x,y,xerr=self.u_x,yerr=self.u_y,name=self.name,linestyle=linestyle,linecolor=linecolor, axes=axes);
     return plot;
Example #2
0
 def plot_fit(self, xmin=None, xmax=None, addto=None, linestyle=None,
              linecolor=None, name=None, axes=None):
     if addto is None:
         plot = ahp.pyg2d()
     else:
         plot = addto
     if xmin is None:
         xmin = self.x.min()
     if xmax is None:
         xmax = self.x.max()
     self.fitx = np.linspace(xmin, xmax, num=1000)
     self.fity = self.fit_at(self.fitx)
     if name is None:
         name = self.name + 'fit'
     plot.add_line(self.fitx, self.fity, name=name,
                   linestyle=linestyle, linecolor=linecolor, axes=axes)
     return plot
Example #3
0
from pyg import twod as pyg
from pym import func as pym
from pyg.colors import pu as puc

plot = pyg.pyg2d()

plot.fill_between([-3., 0.], [-6., -6.], [6., 6.], fc=puc.pu_colors['gray'])
plot.fill_between([0., 5.], [-6., -6.], [-5., -5.], fc=puc.pu_colors['gray'])
plot.fill_between([5., 8.], [-6., -6.], [0., 0.], fc=puc.pu_colors['gray'])

plot.xlim(-3, 8.)
plot.ylim(-6., 6.)
plot.add_text(-1.5, 2., r'I')
plot.add_text(2.5, 3., r'II')
plot.add_text(6.5, 4., r'III')
plot.xticks([0., 5.], [r'$0$', r'$a$'])
plot.yticks([-5, 0., 6], [r'$-V_{0}$', r'$0$', r'$\infty$'])
plot.xlabel(r'$x$')
plot.ylabel(r'$V\left(x\right)$')
plot.export('schrodinger_half_infinite_well',
            formats=['pdf', 'pgf'],
            sizes=['cs'],
            customsize=(1.5, 1.5))
plot.show()