# $Id: PlotItems.py,v 2.4 2001/01/07 21:35:11 mhagger Exp $ # Copyright (C) 1998-2001 Michael Haggerty # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. This program is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details; it is # available at , or by writing to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. """PlotItems.py -- Objects that can be plotted by Gnuplot. This module contains several types of PlotItems. PlotItems can be plotted by passing them to a Gnuplot.Gnuplot object. You can derive your own classes from the PlotItem hierarchy to customize their behavior. """ __cvs_version__ = '$Revision: 2.4 $' import os, string, tempfile try: from cStringIO import StringIO except ImportError: from StringIO import StringIO import Numeric import gp, utils class _unset: """Used to represent unset keyword arguments.""" pass class OptionException(Exception): """Raised for unrecognized option(s)""" pass class DataException(Exception): """Raised for data in the wrong format""" pass class PlotItem: """Plotitem represents an item that can be plotted by gnuplot. For the finest control over the output, you can create 'PlotItems' yourself with additional keyword options, or derive new classes from 'PlotItem'. The handling of options is complicated by the attempt to allow options and their setting mechanism to be inherited conveniently. Note first that there are some options that can only be set in the constructor then never modified, and others that can be set in the constructor and/or modified using the 'set_option()' member function. The former are always processed within '__init__'. The latter are always processed within 'set_option', which is called by the constructor. 'set_option' is driven by a class-wide dictionary called '_option_list', which is a mapping '{