Пример #1
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
Пример #2
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
Пример #3
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
Пример #4
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
Пример #5
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
Пример #6
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
Пример #7
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
Пример #8
0
    def __new__(cls, *args, **kywds):
        """
        quiver(X, Y, Z, U, V, W, **kwargs)
        """
        def set_hidden_vars(obj):
            return obj

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

        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

        p = ArgsParser()
        p.add_var('x', ['numbers|nonstr', 'dynamic'])
        p.add_var('y', ['numbers|nonstr', 'dynamic'])
        p.add_var('z', ['numbers|nonstr', 'dynamic'])
        p.add_var('u', ['numbers|nonstr', 'dynamic'])
        p.add_var('v', ['numbers|nonstr', 'dynamic'])
        p.add_var('w', ['numbers|nonstr', 'dynamic'])
        p.add_key('cz', False, 'bool')
        p.add_key('cdata', None)
        p.set_default_list(default_kargs)
        p.add_key2(("cmap"))
        p.add_key2(("pivot", "pivot"))
        p.add_key("length", 1.0)
        p.add_key("arrow_length_ratio", 0.3)
        p.add_key('alpha', def_alpha)
        p.add_key('facecolor', def_fc)
        p.add_key('edgecolor', def_ec)

        p.set_ndconvert("x", "y", "z", "u", "v", "w", "c")

        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', 'w', 'x', 'y', 'z'):
            obj.setvar(name, v[name])
        for name in ('alpha', 'cmap', 'pivot', 'length', 'arrow_length_ratio',
                     'cz', 'cdata', 'facecolor', 'edgecolor'):
            obj.setvar(name, v[name])

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

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