Python pylab.suptitle() Examples

The following are 3 code examples of pylab.suptitle(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pylab , or try the search function .
Example #1
Source File: multiple_files.py    From orbkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
def contour_mult_mo(self,x,y,mo,xlabel='x',ylabel='y',title='',r0=0):
    '''Uses matplotlib to show slices of a molecular orbitals.'''
    import matplotlib.pyplot as plt
    
    # Plot slices
    f, pics = \
                plt.subplots(len(mo),1,sharex=True,sharey=True,figsize=(6,2+4*len(mo)))
    plt.suptitle(title)
    vmax = numpy.max(numpy.abs(mo))
    for i,pic in enumerate(pics):
      pic.contour(y,x,mo[i],50,linewidths=0.5,colors='k')
      pic.contourf(\
          y,x,mo[i],50,cmap=plt.cm.rainbow,vmax=vmax,vmin=-vmax)
      pic.set_ylabel(xlabel)  
      pic.set_xlabel(ylabel)  
      pic.set_title('Data Point %d' % (r0+i))
    
    f.subplots_adjust(left=0.15,bottom=0.05,top=0.95,right=0.95)
    f.show()
    return f,pics 
Example #2
Source File: dataset_float_classes.py    From DEMUD with Apache License 2.0 5 votes vote down vote up
def  plot_item(self, m, ind, x, r, k, label, U,
                 rerr, feature_weights):

    if x == [] or r == []: 
      print "Error: No data in x and/or r."
      return
  
    pylab.clf()
    # xvals, x, and r need to be column vectors
    # xvals represent bin end points, so we need to duplicate most of them
    x = np.repeat(x, 2, axis=0)
    r = np.repeat(r, 2, axis=0)

    pylab.subplot(2,1,1)
    pylab.semilogx(self.xvals, r[0:128], 'r-', label='Expected')
    pylab.semilogx(self.xvals, x[0:128], 'b.-', label='Observations')
    pylab.xlabel('CTN: ' + self.xlabel)
    pylab.ylabel(self.ylabel)
    pylab.legend(loc='upper left', fontsize=10)

    pylab.subplot(2,1,2)
    pylab.semilogx(self.xvals, r[128:], 'r-', label='Expected')
    pylab.semilogx(self.xvals, x[128:], 'b.-', label='Observations')
    pylab.xlabel('CETN: ' + self.xlabel)
    pylab.ylabel(self.ylabel)
    pylab.legend(loc='upper left', fontsize=10)

    pylab.suptitle('DEMUD selection %d (%s), item %d, using K=%d' % \
                (m, label, ind, k))
  
    outdir = os.path.join('results', self.name)
    if not os.path.exists(outdir):
      os.mkdir(outdir)
    figfile = os.path.join(outdir, 'sel-%d-k-%d-(%s).pdf' % (m, k, label))
    pylab.savefig(figfile)
    print 'Wrote plot to %s' % figfile
    pylab.close() 
Example #3
Source File: prepare.py    From facade-segmentation with MIT License 4 votes vote down vote up
def process_files(files, basedir='./data', debug=False, rectify=False,
                  outdir='./data/for-labelme', **kwargs):
    attempts = 0
    n = len(files)

    print "Rectify is set to", rectify

    try:
        os.makedirs(outdir)
    except OSError as e:
        pass

    if debug:
        try:
            os.makedirs(os.path.join(outdir, 'debug'))
        except OSError as e:
            # Directory already exists
            pass

    for i, f in enumerate(files):
        try:
            newbasename = rename_file(f, basedir)
            newname = os.path.join(outdir, newbasename)
            print i + 1, 'of', n, newname

            image = imread(f)

            if rectify:
                try:
                    meta = {}
                    rectified = rectify_building(image, meta)
                    if debug:
                        import pylab as pl
                        h = meta['homography']
                        pl.suptitle('u:{} d:{} l:{} r:{}'.format(h.du, h.dd, h.dl, h.dr))
                        pl.subplot(221)
                        pl.imshow(image)
                        pl.axis('off')
                        pl.subplot(222)
                        pl.imshow(meta['building'])
                        pl.axis('off')
                        pl.subplot(223)
                        h.plot_original()
                        pl.subplot(224)
                        h.plot_rectified()
                        pl.savefig(os.path.join(outdir, 'debug', newbasename))
                    imsave(newname, rectified)
                except Exception as e:
                    print e
                    pass
            else:
                imsave(newname, image)
        except Exception as e:
            print e