Ignore:
Timestamp:
09/09/05 13:59:41 (19 years ago)
Author:
mar637
Message:

Fixed ps bug, where aspect ratios and sizes weren't handled properly. NOTE. A4 is hardcoded. This needs to be changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Release-2-fixes/python/asaplot.py

    r661 r671  
    380380
    381381
    382     def save(self, fname=None, orientation='landscape'):
     382    def save(self, fname=None, orientation=None):
    383383        """
    384384        Save the plot to a file.
     
    401401        if fname[-3:].lower() in d:
    402402            try:
    403                 self.canvas.print_figure(fname,orientation=orientation)
    404                 print 'Written file %s' % (fname)
     403                if fname[-3:].lower() == ".ps":
     404                    w = self.figure.figwidth.get()
     405                    h = self.figure.figheight.get()                       
     406                    a4w = 8.25
     407                    a4h = 11.25
     408                   
     409                    if orientation is None:
     410                        # auto oriented
     411                        if w > h:
     412                            orientation = 'landscape'
     413                        else:
     414                            orientation = 'portrait'
     415                    ds = None
     416                    if orientation == 'landscape':
     417                        ds = min(a4h/w,a4w/h)
     418                        #self.figure.set_figsize_inches((a4h,a4w))
     419                    else:
     420                        ds = min(a4w/w,a4h/h)
     421                    ow = ds * w
     422                    oh = ds * h
     423                    self.figure.set_figsize_inches((ow,oh))
     424                    self.canvas.print_figure(fname,orientation=orientation)
     425                    print 'Written file %s' % (fname)
     426                else:                   
     427                    self.canvas.print_figure(fname)
     428                    print 'Written file %s' % (fname)
    405429            except IOError, msg:
    406430                print 'Failed to save %s: Error msg was\n\n%s' % (fname, err)
     
    408432        else:
    409433            print "Invalid image type. Valid types are:"
    410             print "ps, eps, png"
     434            print "'ps', 'eps', 'png'"
    411435
    412436
Note: See TracChangeset for help on using the changeset viewer.