Example #1
0
    def __new__(cls, *args, **kywds):
        if kywds.has_key('src'):
            obj = FigPlot.__new__(cls, *args, **kywds)
#            obj = set_hidden_vars(obj)
            obj._use_decimate = True
            return obj
        mpl_cmd, kywds = ProcessKeywords(kywds, 'mpl_command', 'plot')
        mpl_cmd = 'plot' 
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       
        p.add_opt('s', '', 'str')                ### optional argument

#        if mpl_cmd is 'errorbar':

        p.set_ndconvert("x","y")
        p.set_squeeze_minimum_1D("x","y")

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigPlot.__new__(cls, *args, **kywds)
#        obj = set_hidden_vars(obj)
        obj._use_decimate = True
        obj._mpl_cmd = mpl_cmd
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #2
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._image_size = (-1, -1)
            obj._image_scale_str = ('100', '100')
            obj._eps_bbox = (-1, -1, -1, -1)
            obj._image = None
            obj._image_artists = []
            obj._image_alpha = 1.0
            obj._image_scale = (1, 1)
            obj._keep_aspect = True
            obj._anchor_mode = (0,0) # 0 (left or bottom) 1 (center) 2 (right, top)
            obj._resize_mode = True  # True  use normalized coords.
                                     # False evaulate new size from the eps bbox
            return obj

        p = ArgsParser()
        p.add_opt('org_epsfile', None, 'str')
        p.add_opt('xy', [0.2, 0.2], 'numbers')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('xy','org_epsfile'):
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #3
0
    def __new__(cls, *args, **kywds):
        if 'src' in kywds:
            obj = FigPlot.__new__(cls, *args, **kywds)
            #            obj = set_hidden_vars(obj)
            obj._use_decimate = True
            return obj
        mpl_cmd, kywds = ProcessKeywords(kywds, 'mpl_command', 'plot')
        mpl_cmd = 'plot'
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('s', '', 'str')  # optional argument

        #        if mpl_cmd is 'errorbar':

        p.set_ndconvert("x", "y")
        p.set_squeeze_minimum_1D("x", "y")

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigPlot.__new__(cls, *args, **kywds)
        #        obj = set_hidden_vars(obj)
        obj._use_decimate = True
        obj._mpl_cmd = mpl_cmd
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #4
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._drag_backup = None
            obj._drag_mode = 0  # 1 transpose 2 expand 3 rotate
            obj._drag_start = None
            return obj

        if 'src' in kywds:
            obj = FigObjGPHolder.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            obj.setvar('clip', True)  # backword compatiblity should come here
            return obj

        p = ArgsParser()
        p.add_opt('x1', 0.0, ['number', 'dynamic'])
        p.add_opt('y1', 0.0, ['number', 'dynamic'])
        p.add_opt('x2', 1.0, ['number', 'dynamic'])
        p.add_opt('y2', 1.0, ['number', 'dynamic'])
        # special note
        # positions are first moved to _attr and then transferred
        # to gp point.
        # _attr['x1','y1'...] will not be saved.
        # Is it the best way? Also, are others such as done in
        # the same way?
        # Positions are managed by gp. So perhaps, this is not the
        # correct way....

        # attempting to clean this complexty (2014. 07/31)
        # [x1, x2,,] is not transferred to _attr
        # _eval_xy always return the value using getvar
        ###
        p.add_key('width', 1.0)
        p.add_key("arrowstyle", '-|>,head_length=10,head_width=5')
        p.add_key("clip", True)
        p.add_key("trans", ["figure", "figure"] * num_gp)
        p.add_key("transaxes", ["default"] * num_gp)
        p.add_key('draggable', True)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        if isinstance(v['trans'], str):
            v['trans'] = [
                v['trans'],
            ] * num_gp * 2

        obj = FigObjGPHolder.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v:
            obj.setvar(name, v[name])

        if not 'facecolor' in kywds:
            kywds['facecolor'] = 'k'
        if not 'edgecolor' in kywds:
            kywds['edgecolor'] = 'k'
        obj.setvar("kywds", kywds)
        return obj
Example #5
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._image_size = (-1, -1)
            obj._image_scale_str = ('100', '100')
            obj._eps_bbox = (-1, -1, -1, -1)
            obj._image = None
            obj._image_artists = []
            obj._image_alpha = 1.0
            obj._image_scale = (1, 1)
            obj._keep_aspect = True
            obj._anchor_mode = (
                0, 0)  # 0 (left or bottom) 1 (center) 2 (right, top)
            obj._resize_mode = True  # True  use normalized coords.
            # False evaulate new size from the eps bbox
            return obj

        p = ArgsParser()
        p.add_opt('org_epsfile', None, 'str')
        p.add_opt('xy', [0.2, 0.2], 'numbers')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('xy', 'org_epsfile'):
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #6
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....
            obj._drag_backup = None
            obj._drag_mode = 0 # 1 transpose 2 expand 3 rotate
            obj._drag_start = None
            return obj

        if kywds.has_key('src'):
            obj = FigObjGPHolder.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            obj.setvar('clip', True)   ## backword compatiblity should come here
            return obj

        p = ArgsParser()
        p.add_opt('x1', 0.0, ['number', 'dynamic'])
        p.add_opt('y1', 0.0, ['number', 'dynamic'])
        p.add_opt('x2', 1.0, ['number', 'dynamic'])
        p.add_opt('y2', 1.0, ['number', 'dynamic'])
        ### special note
        ###   positions are first moved to _attr and then transferred
        ###   to gp point.
        ###   _attr['x1','y1'...] will not be saved.
        ###   Is it the best way? Also, are others such as done in 
        ###   the same way?
        ###   Positions are managed by gp. So perhaps, this is not the
        ###   correct way....

        ###   attempting to clean this complexty (2014. 07/31)
        ###   [x1, x2,,] is not transferred to _attr
        ###   _eval_xy always return the value using getvar
        ###
        p.add_key('width', 1.0)
        p.add_key("arrowstyle", '-|>,head_length=10,head_width=5')
        p.add_key("clip", True)
        p.add_key("trans", ["figure", "figure"]*num_gp)
        p.add_key("transaxes", ["default"]*num_gp)
        p.add_key('draggable', True)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        if isinstance(v['trans'], str):
             v['trans'] = [v['trans'],]*num_gp*2

        obj = FigObjGPHolder.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v.keys(): 
            obj.setvar(name, v[name])

        if not 'facecolor' in kywds: kywds['facecolor'] = 'k'
        if not 'edgecolor' in kywds: kywds['edgecolor'] = 'k'
        obj.setvar("kywds", kywds)        
        return obj
Example #7
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('v', ['iter|nonstr', 'dynamic'])
        p.add_opt('idxset', None, ['numbers|nonstr', 'dynamic'])

        #p.add_key('cmap', None)

        if 'cz' in kywds and kywds['cz']:
            def_alpha = None
            def_ec = None
            def_fc = None
            def_lw = 0.0
        else:
            def_alpha = 1.0
            def_ec = (0, 0, 0, 1)
            def_fc = (0, 0, 1, 1)
            def_lw = 1.0

        # this prevent from passing linewidth to aritist
        def_lw = kywds.pop('linewidth', def_lw)
        p.add_key('linewidths', def_lw)

        p.add_key('alpha', def_alpha)
        p.add_key('facecolor', def_fc)
        p.add_key('edgecolor', def_ec)
        p.add_key('normals', None)
        p.add_key('cz', False, 'bool')
        p.add_key('cdata', None)
        p.add_key('shade', 'linear')
        p.add_key('array_idx', None)
        p.add_key('edge_idx', None)        
        p.add_key('use_pointfill', False)
        p.add_key('draw_last', False)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #8
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._tri = None
            for key in default_kargs:
                if not obj.hasp(key):
                    obj.setp(key, default_kargs[key])
                if not obj.hasvar(key):
                    obj.setvar(key, default_kargs[key])
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('x', ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('z', None, ['numbers|nonstr'])
        p.add_key('s', 20)
        p.add_key('c', 'b', ['numbers', 'str'])
        p.add_key('marker', 'o')
        p.add_key('sscale', 1.0)
        p.set_ndconvert(
            "x",
            "y",
            "z",
        )
        p.set_squeeze_minimum_1D(
            "x",
            "y",
            "z",
        )
        #        p.set_default_list(default_kargs)
        p.add_key('alpha', 1.0)
        p.add_key('cmap', 'jet')

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x', 'y', 'z', 's', 'c', 'alpha', 'marker', 'sscale'):
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
Example #9
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._drag_backup = None
            obj._drag_mode = 1  # 1 transpose 2 expand 3 rotate
            obj._drag_start = None
            return obj

        if 'src' in kywds:
            obj = FigObjGPHolder.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            obj.setvar('clip', True)  # backword compatiblity should come here
            return obj

        p = ArgsParser()
        p.add_opt('x', 0.5, ['number', 'dynamic'])
        p.add_opt('y', 0.5, ['number', 'dynamic'])
        p.add_opt('z', 0.0, ['number', 'dynamic'])
        p.add_var('s', ['str', 'dynamic'])
        p.set_pair("x", "y")
        p.add_key('draggable', True)
        p.add_key('bbox', dict())
        p.add_key("fancybox", False)
        p.add_key("fbcolor", 'red')
        p.add_key("fbecolor", 'red')
        p.add_key("fbstyle", 'square')
        p.add_key("fbpad", 0.3)
        p.add_key("fbalpha", 1)
        p.add_key("fontfamily", 'sans-serif')
        p.add_key("fontstyle", 'normal')
        p.add_key("fontweight", 'roman')
        p.add_key("multialignment", "left")
        p.add_key("clip", True)
        p.add_key("trans", ["figure", "figure"] * num_gp)
        p.add_key("transaxes", ["default"] * num_gp)

        v, kywds, d, flag = p.process(*args, **kywds)

        if not flag:
            raise ValueError('Failed when processing argument')

        if isinstance(v['trans'], str):
            v['trans'] = [
                v['trans'],
            ] * num_gp * 2

        obj = FigObjGPHolder.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)

        return obj
Example #10
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('v', ['iter|nonstr', 'dynamic']) 
        p.add_opt('idxset', None, ['numbers|nonstr', 'dynamic']) 

        #p.add_key('cmap', None)

        if 'cz' in kywds and kywds['cz']:
            def_alpha = None
            def_ec = None
            def_fc = None
            def_lw = 0.0
        else:
            def_alpha = 1.0
            def_ec = (0, 0, 0, 1)
            def_fc = (0, 0, 1, 1)
            def_lw = 1.0

        # this prevent from passing linewidth to aritist
        def_lw = kywds.pop('linewidth', def_lw)
        p.add_key('linewidths', def_lw)

        p.add_key('alpha', def_alpha)
        p.add_key('facecolor', def_fc)
        p.add_key('edgecolor', def_ec)
        p.add_key('normals', None)
        p.add_key('cz', False, 'bool')
        p.add_key('cdata', None)
        p.add_key('shade', 'linear')
        p.add_key('array_idx', None)
        p.add_key('use_pointfill', False)
        p.add_key('draw_last', False)

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #11
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._data_extent = None
            obj._coarse_artist = None
            obj._fine_artist = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['iter|nonstr', 'dynamic'])
        p.add_opt('y', None, ['iter|nonstr', 'dynamic'])
        p.add_var('z', ['iter|nonstr', 'dynamic'])

        p.add_key('cmap', None)
        p.add_key('shade', 'flat')
        p.add_key('linewidth', 1.0)
        p.add_key('alpha', None)
        p.add_key('rstride', 1)
        p.add_key('cstride', 1)
        p.add_key('edgecolor', 'k')
        p.add_key('facecolor', 'b')
        p.add_key('cz', not 'color' in kywds)
        p.add_key('cdata', None)

        p.set_pair("x", "y")
        p.set_ndconvert("x", "y", "z")
        p.set_squeeze_minimum_1D("x", "y", "z")

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)

        obj = set_hidden_vars(obj)
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']

        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #12
0
    def __new__(cls, *args, **kywds):
        """
        quiver : quiver plot 
        quiver(U, V, **kargs)
        quiver(U, V, C, **kargs)
        quiver(X, Y, U, V, **kargs)
        quiver(X, Y, U, V, C, **kargs)
        """
        def set_hidden_vars(obj):
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('u', ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])
        p.add_opt('c', None, ['numbers|nonstr', 'dynamic'])

        p.set_default_list(default_kargs)
        p.add_key2(("alpha", "cmap"))
        p.add_key2(("pivot", "pivot"))
        p.set_pair("x", "y")  # x and y should be given
        # together
        p.set_ndconvert("x", "y", "u", "v", "c")
#        p.set_squeeze_minimum_1D("x","y","z")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d)

        if not flag:
            raise ValueError('Failed when processing argument')
            return None

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('u', 'v', 'c', 'x', 'y'):
            obj.setvar(name, v[name])
        for name in ('alpha', 'cmap', 'pivot'):
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj
Example #13
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            obj._coarse_artist = None
            obj._fine_artist = None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['iter|nonstr', 'dynamic']) 
        p.add_opt('y', None, ['iter|nonstr', 'dynamic'])       
        p.add_var('z', ['iter|nonstr', 'dynamic']) 


        p.add_key('cmap', None)
        p.add_key('shade', 'flat')
        p.add_key('linewidth', 1.0)
        p.add_key('alpha', None)
        p.add_key('rstride', 1)
        p.add_key('cstride', 1)
        p.add_key('edgecolor', 'k')        
        p.add_key('facecolor', 'b')
        p.add_key('cz',  not 'color' in kywds) 
        p.add_key('cdata', None)                

        p.set_pair("x", "y")
        p.set_ndconvert("x","y","z")
        p.set_squeeze_minimum_1D("x","y","z")

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        
        obj = set_hidden_vars(obj)
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']

        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #14
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'):
                obj._tri = None  # this can go away!?
            for key in default_kargs:
                if not obj.hasp(key):
                    obj.setp(key, default_kargs[key])
                if not obj.hasvar(key):
                    obj.setvar(key, default_kargs[key])
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.set_pair("x", "y")  # x and y should be given
        # together
        p.set_ndconvert("x", "y", "z")
        p.set_squeeze_minimum_1D("x", "y", "z")
        p.set_default_list(default_kargs)
        p.add_key2(('use_tri', 'interp', 'shading', 'alpha'))
        p.add_key('cmap', 'jet')

        v, kywds, d, flag = p.process(*args, **kywds)
        
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x', 'y', 'z', 'use_tri', 'interp', 'shading', 'alpha'):
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
Example #15
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'):
                obj._tri = None  # this can go away!?
            for key in default_kargs:
                if not obj.hasp(key):
                    obj.setp(key, default_kargs[key])
                if not obj.hasvar(key):
                    obj.setvar(key, default_kargs[key])
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('t', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])

        p.set_ndconvert("v", "t")
        p.set_squeeze_minimum_1D("v", "t")
        p.set_default_list(default_kargs)
        p.add_key2(('interp', 'shading', 'alpha', 'window', 'NFFT', 'noverlap',
                    'sides', 'detrend', 'pad_to'))
        p.add_key2('cmap', 'str')
        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in (
                'v',
                't',
                'interp',
                'shading',
                'alpha',
        ):
            obj.setvar(name, v[name])
        obj.setp("use_tri", False)
        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']
        obj.setvar("kywds", kywds)
        return obj
Example #16
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._tri = None
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_var('x', ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('z', None, ['numbers|nonstr'])
        p.add_key('s', 20)
        p.add_key('c', 'b', ['numbers', 'str'])
        p.add_key('marker', 'o')
        p.add_key('sscale', 1.0)        
        p.set_ndconvert("x","y","z",)     
        p.set_squeeze_minimum_1D("x","y","z", )
#        p.set_default_list(default_kargs)
        p.add_key('alpha', 1.0)
        p.add_key('cmap', 'jet')           

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x','y', 'z', 's', 'c', 'alpha',  'marker', 'sscale'): 
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
Example #17
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None ## this can go away!?
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj


        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.set_pair("x", "y")    ### x and y should be given
                                ### together
        p.set_ndconvert("x","y","z")     
        p.set_squeeze_minimum_1D("x","y","z")
        p.set_default_list(default_kargs)
        p.add_key2(('use_tri', 'interp', 'shading', 'alpha'))
        p.add_key('cmap', 'jet')           

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        for name in ('x','y', 'z', 'use_tri', 'interp', 'shading', 'alpha'): 
            obj.setvar(name, v[name])
        if v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        obj.setvar("kywds", kywds)

        return obj
Example #18
0
    def __new__(cls, *args, **kywds):
        if len(args) == 3:
            tri = args[0]
            args = args[1:]
        else:
            tri = None

        def set_hidden_vars(obj):
            obj._other_artists = []
            obj._objs = []  # for debug....
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_key('color', 'b')
        p.add_key('linestyle', '-')
        p.add_key('linewidth', 1.0)
        p.set_ndconvert("x", "y")
        p.set_squeeze_minimum_1D("x", "y")
        p.add_key('mask', None)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        obj.setvar("tri", tri)

        return obj
Example #19
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []
            obj._drag_backup = None
            obj._drag_delta = None
            obj._drag_mode = 0
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_opt('y', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_key('draggable', True)
        p.set_ndconvert("x", "y")
        v, kywds, d, flag = p.process(*args, **kywds)

        # special check for x and y
        if not 'x' in v:
            raise ValueError('can not parse arguments')
        if not 'y' in v:
            raise ValueError('can not parse arguments')
        v["x"], flag2 = _special_xy_check(v["x"])
        v["y"], flag3 = _special_xy_check(v["y"])

        if not flag or not flag2 or not flag3:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)

        obj = set_hidden_vars(obj)
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)

        return obj
Example #20
0
    def __new__(cls, *args, **kywds):
        """
        FigAxline([x1,x2,x3...], [y1,y2,...])
        x is for vertical line
        y is for horizontal line
        """
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....
            obj._drag_backup = None
            obj._drag_delta = None
            obj._data_extent=None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.add_opt('y', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.set_ndconvert("x","y")
        p.add_key('draggable', False)


        v, kywds,d, flag = p.process(*args, **kywds)
        if isinstance(v["x"], float) or isinstance(v["x"], int) :
           v["x"] = [v["x"]]
        if isinstance(v["y"], float) or isinstance(v["y"], int) :
           v["y"] = [v["y"]]

        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)        

        return obj
Example #21
0
    def __new__(cls, *args, **kywds):
        """
        FigAxline([x1,x2,x3...], [y1,y2,...])
        x is for vertical line
        y is for horizontal line
        """
        def set_hidden_vars(obj):
            obj._objs = []  ## for debug....
            obj._drag_backup = None
            obj._drag_delta = None
            obj._data_extent = None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.add_opt('y', [], ['numbers|nonstr', 'dynamic', 'real', 'empty'])
        p.set_ndconvert("x", "y")
        p.add_key('draggable', False)

        v, kywds, d, flag = p.process(*args, **kywds)
        if isinstance(v["x"], float) or isinstance(v["x"], int):
            v["x"] = [v["x"]]
        if isinstance(v["y"], float) or isinstance(v["y"], int):
            v["y"] = [v["y"]]

        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in v.keys():
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)

        return obj
Example #22
0
    def __new__(cls, *args, **kywds):
        if len(args) == 3:
            tri = args[0]            
            args = args[1:]
        else:
            tri = None
            
        def set_hidden_vars(obj):
            obj._other_artists = []
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            return obj
        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       
        p.add_key('color', 'b')
        p.add_key('linestyle', '-')
        p.add_key('linewidth', 1.0)
        p.set_ndconvert("x","y")
        p.set_squeeze_minimum_1D("x","y")
        p.add_key('mask', None)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds) 
        obj.setvar("tri", tri) 

        return obj
Example #23
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs = []  # for debug....
            obj._hit_idx = -1
            obj._hit_seg = -1
            obj._hit_artist = -1
            obj._mesh = 10
            obj._data_extent = None
            obj._data_extent_checked = False
            obj._sp_interp = 1
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])

        p.set_ndconvert("x", "y")
        p.set_squeeze_minimum_1D("x", "y")

        p.add_key('draggable', True)

        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        if v["x"] is None:
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #24
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]  ## for debug....
            obj._hit_idx = -1
            obj._hit_seg = -1
            obj._hit_artist = -1
            obj._mesh = 10
            obj._data_extent=None
            obj._data_extent_checked=False
            obj._sp_interp = 1
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       

        p.set_ndconvert("x","y")
        p.set_squeeze_minimum_1D("x","y")

        p.add_key('draggable', True)

        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        if v["x"] is None:
           v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #25
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._objs=[]
            obj._drag_backup=None
            obj._drag_delta = None
            obj._drag_mode=0
            obj._data_extent=None
            return obj
        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('x', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_opt('y', [], ['can_ndreal_array|nonstr', 'dynamic', 'empty'])
        p.add_key('draggable', True)
        p.set_ndconvert("x","y")
        v, kywds,d, flag = p.process(*args, **kywds)

        ### special check for x and y
        if not 'x' in v: raise ValueError('can not parse arguments')
        if not 'y' in v: raise ValueError('can not parse arguments')
        v["x"], flag2 = _special_xy_check(v["x"])
        v["y"], flag3 = _special_xy_check(v["y"])

        if not flag or not flag2 or not flag3: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)

        obj = set_hidden_vars(obj)
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)        

        return obj
Example #26
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None ## this can go away!?            
            for key in default_kargs:
                if not obj.hasp(key): obj.setp(key, default_kargs[key])
                if not obj.hasvar(key): obj.setvar(key, default_kargs[key])
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        p = ArgsParser()
        p.add_opt('t', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])

        p.set_ndconvert("v", "t")     
        p.set_squeeze_minimum_1D("v","t")
        p.set_default_list(default_kargs)
        p.add_key2(( 'interp', 'shading', 'alpha', 'window', 'NFFT', 
                     'noverlap', 'sides', 'detrend', 'pad_to'))
        p.add_key2('cmap', 'str')
        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        for name in ('v', 't', 'interp', 'shading', 'alpha',): 
            obj.setvar(name, v[name])
        obj.setp("use_tri", False)
        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']
        obj.setvar("kywds", kywds)
        return obj
Example #27
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'plot'
            obj._eb_container = (None, tuple(), tuple())
            obj._other_artists = []
            obj._objs = []  # for debug....
            obj._data_extent = None
            obj._is_decimate = False
            obj._use_decimate = False
            obj._decimate_limit = _decimate_limit
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        mpl_cmd = kywds.pop('mpl_command', 'plot')
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_opt('z', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('s', '', 'str')  # optional argument
        p.add_key('cz', False, 'bool')

        #        if mpl_cmd is 'errorbar':
        p.add_key('xerr', None)
        p.add_key('yerr', None)
        p.add_key('ecolor', None)
        p.add_key('elinewidth', None)
        p.add_key('array_idx', None)
        if 'cz' in kywds and kywds['cz']:
            p.add_key('cmap', 'jet')
        p.add_key('c', None)

        p.set_ndconvert("x", "y", "z", "xerr", "yerr", "c")
        p.set_squeeze_minimum_1D("x", "y", "z", "xerr", "yerr", "c")
        v, kywds, d, flag = p.process(*args, **kywds)
        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1]).astype(v["y"].dtype)
        if 'cmap' in v and v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap):
                v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #28
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'plot'
            obj._eb_container = (None, tuple(), tuple())
            obj._other_artists = []
            obj._objs=[]  ## for debug....     
            obj._data_extent=None
            obj._is_decimate = False
            obj._use_decimate = False
            obj._decimate_limit = _decimate_limit
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        mpl_cmd = kywds.pop('mpl_command', 'plot')
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic']) 
        p.add_var('y', ['numbers|nonstr', 'dynamic'])       
        p.add_opt('z', None, ['numbers|nonstr', 'dynamic']) 
        p.add_opt('s', '', 'str')                ### optional argument
        p.add_key('cz', False, 'bool')

#        if mpl_cmd is 'errorbar':
        p.add_key('xerr', None)
        p.add_key('yerr', None)
        p.add_key('ecolor', None)
        p.add_key('elinewidth', None)
        p.add_key('array_idx', None)        
        if 'cz' in kywds and kywds['cz']:
            p.add_key('cmap', 'jet')
        p.add_key('c',  None)                           

        p.set_ndconvert("x","y","z","xerr","yerr", "c")
        p.set_squeeze_minimum_1D("x","y","z","xerr","yerr", "c")
        v, kywds,d, flag = p.process(*args, **kywds)
        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if (v["x"] is None and not isdynamic(v["y"])):
            v["x"] = np.arange(v["y"].shape[-1]).astype(v["y"].dtype)
        if 'cmap' in v and v['cmap'] is not None:
            if isinstance(v['cmap'], Colormap): v['cmap'] = v['cmap'].name
            kywds['cmap'] = v['cmap']
            del v['cmap']
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #29
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'fill'
            obj._data_extent = None
            return obj

        if 'src' in kywds:
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        mpl_cmd, kywds = ProcessKeywords(kywds, 'mpl_command', 'fill')
        p = ArgsParser()

        if mpl_cmd == 'fill_betweenx':
            p.add_var('y', ['iter|nonstr', 'dynamic'])
            p.add_opt('x', None, ['iter|nonstr', 'dynamic'])
        else:
            p.add_opt('x', None, ['iter|nonstr', 'dynamic'])
            p.add_var('y', ['iter|nonstr', 'dynamic'])
        if mpl_cmd == 'fill':
            p.add_opt('s', '', 'str')

        p.add_key('x2', None)
        p.add_key('y2', None)
        p.add_key('where', None)
        p.add_key('edgecolor', 'black')
        p.add_key('linewidth', 1.0)
        p.add_key('linestyle', 'solid')
        p.add_key('alpha', 1)
        p.add_key('facecolor', 'blue')
        p.add_key('zs', 0)

        p.set_ndconvert("x", "y", "x2", "y2")

        v, kywds, d, flag = p.process(*args, **kywds)

        if not flag:
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if v["x"] is None:
            v["x"] = np.arange(v["y"].shape[-1])
        for name in v:
            obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #30
0
    def __new__(cls, *args, **kywds):
        def set_hidden_vars(obj):
            obj._mpl_cmd = 'fill'
            obj._data_extent=None
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj

        mpl_cmd, kywds = ProcessKeywords(kywds, 'mpl_command', 'fill')
        p = ArgsParser()

        if mpl_cmd == 'fill_betweenx':
            p.add_var('y', ['iter|nonstr', 'dynamic'])       
            p.add_opt('x', None, ['iter|nonstr', 'dynamic']) 
        else:
            p.add_opt('x', None, ['iter|nonstr', 'dynamic']) 
            p.add_var('y', ['iter|nonstr', 'dynamic'])       
        if mpl_cmd == 'fill':
            p.add_opt('s', '', 'str')

        p.add_key('x2', None)
        p.add_key('y2', None)
        p.add_key('where', None)
        p.add_key('edgecolor', 'black')
        p.add_key('linewidth', 1.0)
        p.add_key('linestyle', 'solid')
        p.add_key('alpha', 1)
        p.add_key('facecolor', 'blue')
        p.add_key('zs', 0)

        p.set_ndconvert("x","y", "x2", "y2")

        v, kywds,d, flag = p.process(*args, **kywds)

        if not flag: 
            raise ValueError('Failed when processing argument')

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)
        obj._mpl_cmd = mpl_cmd
        if v["x"] is None:
           v["x"] = np.arange(v["y"].shape[-1])
        for name in v.keys(): obj.setvar(name, v[name])
        obj.setvar("kywds", kywds)
        return obj
Example #31
0
    def __new__(cls, *args, **kywds):
        """
        contour : contour plot 
        contour(z, n)  
        contour(x, y, z, n)  
        contour(z, v)  
        contour(x, y, z, v)  

        n: number of levels
        v: a list of contour levels
        """
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None  ## this can go away!?
            obj._clabels = []
            obj._clabel_param = def_clabel_param
            obj._nouse_expression = False
            obj._hit_path = None
            obj._expression = ''
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr', 'dynamic'])
        p.add_opt('y', None, ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.add_opt('n', 7, 'int')  ### n = number of levels
        p.add_opt('v', None,
                  ['numbers|nonstr', 'dynamic'])  ### v = levels (array)

        p.set_default_list(default_kargs)
        p.add_key2(("FillMode", "alpha"))
        p.add_key2('interp', 'str')
        p.add_key2('cmap', 'str')
        p.add_key('offset', None)
        p.add_key('zdir', 'z')

        p.set_pair("x", "y")  ### x and y should be given
        ### together
        p.set_ndconvert("x", "y", "z")
        p.set_squeeze_minimum_1D("x", "y", "z")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d)

        if not flag:
            raise ValueError('Failed when processing argument')
            return None

        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        obj._set_expression_vars(v['v'])
        for name in ('x', 'y', 'z'):
            obj.setvar(name, v[name])
        for name in ('FillMode', 'alpha', 'n', 'v', "cmap", "offset", "zdir"):
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj
Example #32
0
    def __new__(cls, *args, **kywds):
        """
        contour : contour plot 
        contour(z, n)  
        contour(x, y, z, n)  
        contour(z, v)  
        contour(x, y, z, v)  

        n: number of levels
        v: a list of contour levels
        """
        def set_hidden_vars(obj):
            if not hasattr(obj, '_tri'): obj._tri = None ## this can go away!?
            obj._clabels = []
            obj._clabel_param = def_clabel_param 
            obj._nouse_expression = False 
            obj._hit_path = None
            obj._expression = ''
            return obj

        if kywds.has_key('src'):
            obj = FigObj.__new__(cls, *args, **kywds)
            obj = set_hidden_vars(obj)
            return obj
        p = ArgsParser()
        p.add_opt('x', None, ['numbers|nonstr','dynamic'])
        p.add_opt('y', None, ['numbers|nonstr','dynamic'])
        p.add_var('z', ['numbers|nonstr','dynamic'])
        p.add_opt('n', 7, 'int')              ### n = number of levels
        p.add_opt('v', None, ['numbers|nonstr', 'dynamic'])   ### v = levels (array)

        p.set_default_list(default_kargs)
        p.add_key2(("FillMode", "alpha"))
        p.add_key2('interp', 'str')
        p.add_key2('cmap', 'str')
        p.add_key('offset', None)
        p.add_key('zdir', 'z')

        p.set_pair("x", "y")                     ### x and y should be given
                                                 ### together
        p.set_ndconvert("x","y","z") 
        p.set_squeeze_minimum_1D("x","y","z")

        v, kywds, d, flag = p.process(*args, **kywds)
        dprint2(d) 

        if not flag: 
            raise ValueError('Failed when processing argument')
            return None


        obj = FigObj.__new__(cls, *args, **kywds)
        obj = set_hidden_vars(obj)

        obj._set_expression_vars(v['v'])
        for name in ('x','y', 'z'): 
            obj.setvar(name, v[name])
        for name in ('FillMode','alpha', 'n', 'v', "cmap", "offset", "zdir"): 
            obj.setvar(name, v[name])

        if v['cmap'] is not None:
            kywds['cmap'] = v['cmap']

        obj.setvar("kywds", kywds)
        return obj