Changeset 376 for trunk/python


Ignore:
Timestamp:
02/08/05 09:19:53 (20 years ago)
Author:
mar637
Message:
  • Added argument nplots to set_panels to support user setting of those, while not plotting in 'excess' panels.
  • Added help to save.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asaplot.py

    r226 r376  
    1616from matplotlib.figure import Figure, Text
    1717from matplotlib.numerix import sqrt
     18from matplotlib import rc,rcParams
    1819
    1920# Force use of the newfangled toolbar.
     
    7071        matplotlib.interactive = True
    7172        self.buffering = buffering
    72 
     73       
    7374        self.canvas.show()
    7475
     
    465466
    466467
    467     def set_panels(self, rows=1, cols=0, n=-1):
     468    def set_panels(self, rows=1, cols=0, n=-1, nplots=-1):
    468469        """
    469470        Set the panel layout.
     
    499500            if i*(i-1) >= rows: i -= 1
    500501            rows = i
    501            
     502        else:
     503            if nplots > -1:
     504                nel=nplots
    502505        if 0 <= n < rows*cols:
    503506            i = len(self.subplots)
     
    511514        else:
    512515            self.subplots = []
    513             for i in range(0,nel):
     516            for i in range(nel):
    514517                self.subplots.append({})
    515518                self.subplots[i]['axes']  = self.figure.add_subplot(rows,
     
    589592        """
    590593        self.figure.text(*args, **kwargs)
    591         self.show()
    592 
     594        self.show()       
    593595
    594596    def unmap(self):
     
    609611
    610612    def save(self, fname=None):
     613        """
     614        Save the plot to a file. The know formats are 'png', 'ps', 'eps'.
     615        Parameters:
     616             filename:    The name of the output file. This is optional
     617                          and autodetects the image format from the file
     618                          suffix. If non filename is specified a file
     619                          called 'yyyymmdd_hhmmss.png' is created in the
     620                          current directory.
     621        """
    611622        if fname is None:
    612623            from datetime import datetime
     
    618629            try:
    619630                self.canvas.print_figure(fname)
     631                print 'Written file %s' % (fname)
    620632            except IOError, msg:
    621633                print 'Failed to save %s: Error msg was\n\n%s' % (fname, err)
     
    623635        else:
    624636            print "Invalid image type. Valid types are:"
    625             print d
     637            print "ps, eps, png"
    626638
    627639
Note: See TracChangeset for help on using the changeset viewer.